$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
$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