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



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
  • 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
  • 1
    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 clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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