Get the last logon dates for enabled Computer objects in AD:
Get-ADComputer -Filter {(Enabled -eq $True)} -Properties * | Sort LastLogonDate | FT Name, LastLogonDate -Autosize | Out-File C:\Temp\ComputerLastLogonDate.txt
An alternative, specifying OU, different columns, and outputting to CSV:
Get-ADComputer -searchbase "CN=Computers,DC=fabrikam,DC=local" -filter * -Properties LastLogonTimeStamp,LastLogonDate,Name,Description,Created|Select Name,DistinguishedName,Created,LastLogonDate,@{n='LastLogonTimestamp';e={[DateTime]::FromFileTime($_.LastLogonTimeStamp)}},Description,DNSHostName,Enabled | export-csv C:\temp\Output.csv
No comments:
Post a Comment