Get AD User expiration date from PowerShell


 Get AD User expiration date from PowerShell


To get the user expiration date on Active Directory from Powershell with proper formatting.

Try the below cmdlet.

Get-ADUser -Identity xxxxxx –Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" | Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}






1 comment:

  1. Ok, but how do I turn that into a variable I can use.
    Like if I want to store the ExpiryDate so I can perform actions on it.
    I have looked at like 40 web pages and they all either generate giant lists from the AD or display some readout. But none show how to take this information, store it in a variable, and take action based on its' value.
    Thanks

    ReplyDelete