August 2019
Intermediate to advanced
786 pages
20h 22m
English
Periodic housekeeping in AD is required for integrity. There may be user objects that have not been used for years. If we can create a report along with the last login dates, we can use it as a reference to clean up objects:
## Script For Filter user with Last logon Time ##$htmlformat = "<style>BODY{background-color:LightBlue;}</style>"Get-ADUser -Filter * -Properties "LastLogonDate" | sort-object -property lastlogondate -descending | Select-Object Name,LastLogonDate | ConvertTo-HTML -head $htmlformat -body "<H2>AD Accounts Last Login Date</H2>"| Out-File C:\lastlogon.htmlInvoke-Expression C:\lastlogon.html
This script creates an HTML report that includes all the user accounts with their last logon date timestamps: ...
Read now
Unlock full access