Untitled
The first where clause is to filter out pwdLastSet == null or 0 via Active Directory Technical Specification Powershell $_."msDS-UserPasswordExpiryTimeComputed" -ne 0 Expires within today at midnight through the next 7 days Powershell Get-ADUser -filter {Enabled -eq $true -and PasswordNeverExpires -eq $false -and PasswordExpired -eq $false} -Properties "Name", "EmailAddress", "msDS-UserPasswordExpiryTimeComputed" | Where-Object {$_."msDS-UserPasswordExpiryTimeComputed" -ne 0} | Select-Object -Property "Name", "EmailAddress", @{Name = "PasswordExpiry"; Expression = {[datetime]::FromFileTime($_."msDS-UserPasswordExpiryTimeComputed")}} | Where-Object {$_.PasswordExpiry -ge (Get-Date).Date -and $_.PasswordExpiry -le (Get-Date).Date.AddDays(7)}
Leave a Comment