Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

Search for active computers with last 90 days

$
0
0

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


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>