Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Inactive user 90 days to include lastlogin formatting lastlogonTimestamp when exporting to CSV

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>