Skip to content

Instantly share code, notes, and snippets.

@ergosteur
Last active April 18, 2020 19:39
Show Gist options
  • Save ergosteur/8a8907c3fdf39b701a4674b7251a419c to your computer and use it in GitHub Desktop.
Save ergosteur/8a8907c3fdf39b701a4674b7251a419c to your computer and use it in GitHub Desktop.
# Source: https://activedirectorypro.com/how-to-get-ad-users-password-expiration-date/
$cred = Get-Credential
Get-ADUser -server domaincontroller.domain -credential $cred -filter {Description -like "SRI*" -and Enabled -eq $True -and PasswordNeverExpires -eq $False} -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |
Select-Object -Property "Displayname",@{Name="ExpiryDate";Expression={[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment