Search-ADAccount -UsersOnly -SearchBase "ou=Path,ou=To,ou=OrgUnit,dc=example,dc=com" -AccountInactive -TimeSpan 90 |
Get-ADUser -Properties Name, sAMAccountName, givenName, sn, lastLogonTimestamp, userAccountControl | Where {($_.userAccountControl -band 2) -eq $False} |
Select sAMAccountName, givenName, sn, @{n="LastLogonTimeStamp";e={[DateTime]::FromFileTime($_.lastlogon)}} |
Sort-Object sAMAccountName | export-csv c:\report\90day-Inactive-users.csv -NoTypeInformation
the format is coming as "12/31/1600 4:00:00 PM" for all users ???