Hi everyone,
I would like to search entire domain for XP and Win 7 Pro computers that active within last 90 days. I have script below but it appear to return all computers back to 2010. What is wrong with this script? Thanks in advance.
$DaysInactive = 90
$time = (Get-Date).Adddays(-($DaysInactive))
# Get all AD computers with lastLogonTimestamp less than our time
Get-ADComputer -Filter {LastLogonTimeStamp -gt $time -and OperatingSystem -like "Windows XP Professional" -or OperatingSystem -like "Windows 7 Professional"} -Properties LastLogonTimeStamp, OperatingSystem, description |
# Output hostname and lastLogonTimestamp into CSV
select-object Name,OperatingSystem,description,@{Name="Stamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}} | export-csv 'C:\WinXP_Pro_Active_Computer.csv' -notypeinformation