Getting the password expiry date of user accounts

The function discussed in this section helps in retrieving the password expiry date of the users in the domain. The good thing with this function is that it makes use of the msDS-UserPasswordExpiryTimeComputed attribute of the user accounts to determine the password expiry date. This attribute stores a dynamic value that indicates the date and time when the password of the user is going to expire. This value will be in the FileTime format. This function looks for user accounts that are enabled and has the PasswordNeverExpires attribute set to false:

Function Get-PasswordExpiryDetails { [CmdletBinding()] Param( ) $Users = Get-ADUser -Filter {PasswordNeverExpires -eq $false -and Enabled -eq $true} ...

Get Active Directory with PowerShell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.