Powershell to Send Password Change Notification


posted by Krishna
01-19-2010

Downloads: 468
File size: 957 B
Views: 3,053

Embed
Powershell to Send Password Change Notification
  1. Add-PSSnapin Quest.ActiveRoles.ADManagement 
  2. $PasswordAgeMax    = (Get-QADObject (Get-QADRootDSE).defaultNamingContextDN).MaximumPasswordAge.days 
  3. Get-Content "C:\Powershell\PasswordChangeNotification\Masterusers.txt" | foreach
  4. $PasswordAge = $PasswordAgeMax - ((Get-QADUser -Identity $_ ).passwordage.days
  5. $PasswordAge = [int]$PasswordAge 
  6. if ($PasswordAge -le 10 -and $PasswordAge -ge 0){ 
  7. $emailFrom = "Administrator@domain.com" 
  8. $emailTo = $_ 
  9. $subject = "Your Password Will Expires in $PasswordAge Days" 
  10. $body = " 
  11. Your password will expire in $PasswordAge days.  Kindly change your password ASAP. 
  12. To change your password login to webmail then click on Options (Top left corner) and change password. 
  13. If you experience any further issues relating to this please contact your local IT support  
  14.  
  15. Global IT" 
  16. $smtpServer = "SMTPServer" 
  17. $smtp = new-object Net.Mail.SmtpClient("SMTPServer"
  18. $smtp.Send($emailFrom, $emailTo, $subject, $body
  19. $_ 

Hi,

Attached powershell helps to send Password change notification when it reached last 10 days. It will sent until it reached the last day.

Regadrs,
Krishna
http://smtpport25.wordpress.com

Concentrated Tech NSoftware Dell Compellent Sponsored by Idera and Concentrated Tech and NSoftware and Dell Compellent
Copyright 2011 PowerShell.com. All rights reserved.