Windows – Last computer account password change via Powershell

active-directorypowershellwindows

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

Best Answer

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