Last computer account password change via Powershell

17,165

http://www.rlmueller.net/PwdLastChanged.htm

http://blogs.metcorpconsulting.com/tech/?p=1369
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:
17,165

Related videos on Youtube

Volodymyr Molodets
Author by

Volodymyr Molodets

Updated on September 18, 2022

Comments

  • Volodymyr Molodets
    Volodymyr Molodets over 1 year

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

  • Volodymyr Molodets
    Volodymyr Molodets over 11 years
    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)(operating‌​System=Windows Server*))" -limit 10000 -uco >C:\output.txt
  • Volodymyr Molodets
    Volodymyr Molodets over 11 years
    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