PowerShell: Know Password expiry date of Active Directory Users

PowerShell: Know Password expiry date of Active Directory Users

This is a easy PowerShell script that shows Password expiry dates of Active Directory user.  You could use the same command to get password expiry date of users in a group, OU or for all domain users.

Example 1: Get Password Expiry date of all users in Active Directory domain

Get-ADUser -Filter {Enabled -eq “True”} -Properties Name, msDS-UserPasswordExpiryTimeComputed | Select Name,@{Name=”Expiry Date”;Expression={[datetime]::FromFileTime($_.”msDS-UserPasswordExpiryTimeComputed”)}}

Example 2: Get Password Expiry date of all users that are member of Group Name Marketing

$users = Get-ADGroupMember “Marketing”

foreach ($user in $users) {Get-ADUser -Filter {Enabled -eq “True” -AND Name -eq $user.name} -Properties Name, msDS-UserPasswordExpiryTimeComputed | Select Name,@{Name=”Expiry Date”;Expression={[datetime]::FromFileTime($_.”msDS-UserPasswordExpiryTimeComputed”)}}}

Example 3: Get Password Expiry date of all users that are in the Test OU.

Get-ADUser -SearchBase “OU=Test,DC=Contoso,DC=Com” -Filter {Enabled -eq “True”} -Properties Name, msDS-UserPasswordExpiryTimeComputed | Select Name, @{Name=”Expiry Date”;Expression={[datetime]::FromFileTime($_.”msDS-UserPasswordExpiryTimeComputed”)}}}

 

 

 

About The Author

Related posts

Leave a Reply

Your email address will not be published. Required fields are marked *