PowerShell - Get-ADComputer last password change, Find Stale objects
- Jon Boyette
- Jan 11, 2022
- 1 min read
Populate c:\temp\servers.txt, can copy and paste this or save as a named .ps1, Also information how AD resets the computer password every 30 days, or as long as a machine is online. if you have output that is past 30 days you know the machine has not been on the domain for an auto reset
********For computers, the "pwdlastset/PasswordLastSet" will be the last time the computer account reset its secure channel.********
$computers = get-content C:\temp\servers.txt
ForEach ($comp in $computers)
{
Get-ADComputer $comp -Properties PasswordLastSet | Where {$_.Passwordlastset -ge (Get-date).AddDays(-30)}| Select-Object Name,PasswordLastSet | Export-CSV C:\temp\PasswordLastSet.csv -append -force -NoTypeInformation
}
Comments