top of page

PowerShell - List all Stale Computers in AD, Set at 90 days currently

  • Writer: Jon Boyette
    Jon Boyette
  • Jan 7, 2022
  • 1 min read

Can tweak the days however needed, change the -90, to a -120, -30, -60 etc, and the output is the servers that have been stale that long in AD, By using the Computer Object, and when the computer password last set, or logged in. This is searching from a defined OU



Import-Module ActiveDirectory

$date = [DateTime]::Today.AddDays(-90)

Get-ADComputer -Filter ‘PasswordLastSet -le $date’ -SearchBase "OU=servers,dc=DOMAIN,dc=COM" -properties PasswordLastSet | Export-Csv -path C:\temp\ServersStale90days_$((Get-Date).ToString('MM-dd-yyyy')).csv -NoTypeInformation







 
 
 

Recent Posts

See All
PowerShell - List All Domain SPNs

Save as same List_ALL_SPNs.ps1 or similar, this LDap calls the Domain for all Service Principal names and accounts related #Build LDAP...

 
 
 
PowerShell - Start-Monitoring

This is a great script used to Monitor and Email if a server is up or down, once ran, and smtp and from address is set, then run:...

 
 
 

Comments


Post: Blog2 Post
  • Facebook
  • Twitter
  • LinkedIn

©2022 by Boyette Technical Services. Proudly created with Wix.com

bottom of page