How Old is the Admin Password

Here’s a quick one-liner to find out how old the administrator password age (in days) is on a remote machine.

PS C:\> ([adsi]“WinNT://COMPUTERNAME/administrator”).passwordage.value/86400

This requires RPC/DCOM access to the remote computer. Or use PowerShell remoting with Invoke-Command:

invoke-command {
new-object PSObject -property @{
Computername = $env:computername
AdminAge = ([adsi]“WinNT://$env:computername/administrator”).passwordage.value/86400
}
} -ComputerName $computers | Select Computername,AdminAge

About the Author

PowerShell.org Announcer

This is the official account for PowerShell.org and sponsor announcements.