top of page

PowerShell - List Stale Workstations in AD, Currently set to -120 days

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

Set as desired, searches the Workstations and add domain for OU. Outouts to c:\temp\workstationsstale120days - date.csv. This tests the computer object or Get-ADComputer passwordlastset. This shows the object not logged into the - days defined.



Import-Module ActiveDirectory

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

Get-ADComputer -Filter ‘PasswordLastSet -le $date’ -SearchBase "OU=workstations,dc=domain,dc=com" -properties PasswordLastSet | Export-Csv -path C:\temp\WorkstationsStale120days_$((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