no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
— | windows:scripting:password_expire [2020/05/20 12:47] (current) – created - external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Get AD password expire time ====== | ||
+ | <code powershell> | ||
+ | $users = Get-ADUser -filter {Enabled -eq $True -and PasswordNeverExpires -eq $False} –Properties " | ||
+ | foreach ($user in $users) { | ||
+ | if (($user.ExpiryDate -ne $null) -and ($user.DisplayName -ne $null) -and ($user.mail -ne $null)) { | ||
+ | $diff = New-Timespan -End $user.ExpiryDate.ToString(" | ||
+ | if (($diff.days -le 15) -and ($diff.days -gt 0)) { | ||
+ | Send-MailMessage -To $user.mail -From " | ||
+ | } | ||
+ | if ($diff.days -eq 0) { | ||
+ | Send-MailMessage -To $user.mail -From " | ||
+ | } | ||
+ | if ($diff.days -le 0) { | ||
+ | Send-MailMessage -To $user.mail -From " | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | Create task schedule and run script daily |