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
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
Post a Comment