PowerShell - Get Password Expiration for all non Disabled Users in AD PowerShell - Get Password Expiration for all non Disabled Users in AD powershell powershell

PowerShell - Get Password Expiration for all non Disabled Users in AD


Here's a revised version of your script without looping issues:

$reportObject = @()$userList = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq  $False} -Properties "DisplayName", "msDS-UserPasswordExpiryTimeComputed" |  Where-Object {$_.DisplayName -ne $null}$userList | %{    $output = "" | Select DisplayName, ExpiryDate    $output.DisplayName = $_.DisplayName    $output.ExpiryDate = ([datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).DateTime    $reportObject += $output    #Next 2 Lines provide debugging... I'm not sure the date time portion will work without having AD to play with    $output | fl *    ([datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")).DateTime }$reportObject | Convertto-CSV -NoTypeInformation