Avatar of Indie101
Indie101
 asked on

Powershell script to check computers not logged onto for one year

Looking for a script (on the one line) to find number of computers who haven't logged on in over a year

I know its better to use last logon date rather than last logon can someone supply a powershell script for this please?
Powershell

Avatar of undefined
Last Comment
Indie101

8/22/2022 - Mon
Dorababu M

Try this

import-module activedirectory  
$domain = "domain.mydom.com"  
$DaysInactive = 365  
$time = (Get-Date).Adddays(-($DaysInactive)) 
Get-ADComputer -Filter {LastLogonTimeStamp -lt $time} -Properties LastLogonTimeStamp |   
select-object Name,@{Name="Stamp"; Expression={[DateTime]::FromFileTime($_.lastLogonTimestamp)}}

Open in new window

ASKER CERTIFIED SOLUTION
oBdA

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Indie101

ASKER
Thank you both :)
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes