Sign up ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Does anybody know how to get last computer account password change for all servers in a domain via powershell?

share|improve this question

1 Answer 1

up vote 1 down vote accepted
From the above link :

Import-Module activedirectory
[int]$ComputerPasswordAgeDays = 90
IF ((test-path "c:\temp") -eq $False) { md "c:\temp" }
$ExportFile = "c:\temp\InactiveWorkstations.csv"
$ComputerStaleDate = (Get-Date).AddDays(-$ComputerPasswordAgeDays)
$InactiveWorkstations = Get-ADComputer -filter { (passwordLastSet -le $ComputerStaleDate) -and (OperatingSystem -notlike "*Server*") -and (OperatingSystem -like "*Windows*") } -properties Name, DistinguishedName, OperatingSystem,OperatingSystemServicePack, passwordLastSet,LastLogonDate,Description
$InactiveWorkstations | export-csv $ExportFile
share|improve this answer
Pretty good! Used the attribute name from the first article in conjunction with dsquery tool to get info about all servers in a domain: dsquery * -scope subtree -attr "cn" "operatingSystem" "operatingSystemServicePack" "pwdLastSet" -filter "(&(objectclass=computer)(objectcategory=computer)(operatingSystem=Windows Server*))" -limit 10000 -uco >C:\output.txt – Volodymyr M. Nov 5 '12 at 14:12
Perhaps, it is worth mentioning what values returned by pwdLastSet attribute are not human readable at all. Here is an article on how to convert these values into human readable Converting LDAP dates – Volodymyr M. Nov 5 '12 at 14:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.