June 2017
Beginner to intermediate
742 pages
18h 29m
English
Periodic housekeeping in AD is required for integrity. There can be user objects which not been used for years. If we can create report along with last login dates, we can use it as reference to clean up the 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 a HTML report which includes all the user accounts with their last log on date time stamps: