Wednesday 29 April 2020

Last Logon Date



Get-ADUser <samAccountName> -Properties * | fl Enabled,SamAccountName,Name,@{n="LastLogon";e={[datetime]::FromFileTime($_.lastLogon)}}


Get-ADUser -Filter * -Properties Enabled,SamAccountName,Name,LastLogon| `
Where {([datetime]::FromFileTime($_.lastLogon) -lt (Get-Date).AddDays(-90))} | `
Select Enabled,SamAccountName,Name,@{n="LastLogon";e={[datetime]::FromFileTime($_.lastLogon)}}