Powershell script for all AD user with Lastlogontimestamp

Powershell script for all AD user with Lastlogontimestamp:

Get-ADUser -Filter * -Properties name,samaccountname,enabled,emailaddress,DistinguishedName,description,Lastlogontimestamp,lastlogondate,Department,whenCreated,location | Select-object name,samaccountname,enabled,emailaddress,DistinguishedName,description,lastlogondate,Department,whenCreated,location,@{Name="LastLogonTimeStamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp).ToString('yyyy-MM-dd_hh:mm:ss')}} | Sort-Object -Property Name | Export-Csv FILENAME.csv

Comments

Popular posts from this blog

Troubleshooting Netlogon Error Codes

Service Principal Names (SPNs) SetSPN Syntax (Setspn.exe)

Troubleshooting AD Active Directory Replication Error 8456 or 8457: "The source | destination server is currently rejecting replication requests"