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} `-Properties msDS- UserPasswordExpiryTimeComputed,* Foreach($User in $Users) { $OutputObj = New-Object -TypeName PSObject -Property @{ UserName = $User.Name; DisplayName = $null; PwdExpirtyDate = $null; PwdExpiryInDays...