PowerShell – Inactive accounts

$date = (get-date).AddDays(-90)

Get-ADUser -Filter {LastLogonDate -lt $date} -Property Enabled | Where-Object {$_.Enabled -like “true”} | Select Name, SamAccountName, DistinguishedName | Export-CSV “C:\Temp\Inactiveaccounts.csv” -NoTypeInformation

Leave a Reply

Your email address will not be published. Required fields are marked *