Skip to content
Menu
The Lonely Administrator
  • PowerShell Tips & Tricks
  • Books & Training
  • Essential PowerShell Learning Resources
  • Privacy Policy
  • About Me
The Lonely Administrator

How Old is the Admin Password

Posted on April 1, 2013March 28, 2014

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

([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

 

Share this:

  • Print (Opens in new window) Print

Like this:

Like Loading…

Related

4 thoughts on “How Old is the Admin Password”

  1. mikef2691 says:
    April 1, 2013 at 9:02 pm

    OK, I got a number back. 862.877465277778. Is that days, weeks, seconds??

    1. Jeffery Hicks says:
      April 1, 2013 at 9:11 pm

      That should be the number of days.

  2. Pingback: Get Local Admin Group Members in a New Old Way | The Lonely Administrator
  3. Chuck Mella says:
    September 27, 2013 at 7:55 am

    Great on-liner, I use it continually in our enterprise. For readability in one of my scheduled tasks that sends out overview emails, I added formatting to limit the returned data to one decimal point (boss no likey long numbers). My modification below:

    “{0:N1}” -f (([adsi]”WinNT://COMPUTERNAME/administrator”).passwordage.value/86400)

Comments are closed.

The PowerShell Practice Primer
Learn PowerShell in a Month of Lunches Fourth edition


Get More PowerShell Books

Other Online Content

github



PluralSightAuthor

Active Directory ADSI Automation Backup Books CIM CLI conferences console Friday Fun FridayFun Function functions Get-WMIObject GitHub hashtable HTML Hyper-V Iron Scripter ISE Measure-Object module modules MrRoboto new-object objects Out-Gridview Pipeline PowerShell PowerShell ISE Profile prompt Registry Regular Expressions remoting SAPIEN ScriptBlock Scripting Techmentor Training VBScript WMI WPF Write-Host xml

©2026 The Lonely Administrator | Powered by SuperbThemes!
%d