I'm trying to create a report for AD users account that their passwords will expired within 7 days based on PowerShell script:
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)}Any idea how to create a daily report or an alert for that??
Thanks