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.

Manage and Report Active Directory, Exchange and Microsoft 365 with
ManageEngine ADManager Plus - Download Free Trial

Exclusive offer on ADManager Plus for US and UK regions. Claim now!
([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

 


Behind the PowerShell Pipeline

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to print (Opens in new window) Print
  • Click to email a link to a friend (Opens in new window) Email

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.

reports

Powered by Buttondown.

Join me on Mastodon

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

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