PowerShell – Find inactive Pc’s

This will list out all the PC names and information who has been inactive for 180 Days:

$DaysInactive = 180
$time = (Get-Date).Adddays(-($DaysInactive))
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -ResultPageSize 2000 -resultSetSize $null -Properties Name, OperatingSystem, DistinguishedName | Export-CSV “IdleComps.csv” –NoTypeInformation