Password Expiry Email Notification

This script will email a user in the event that their password is due to expire in X number of days.

 
 
 
 
 
4.6 Star
(153)
81,372 times
Add to favorites
Active Directory
8/7/2018
E-mail Twitter del.icio.us Digg Facebook
Sign in to ask a question


  • Error
    1 Posts | Last post Thu 1:49 AM
    • PS D:\Password_Reminder_Scripts> .\PasswordChangeNotification.ps1 -smtpServer exch-mb -expireInDays 309 -from "Password Reminder <password_reminder@domain.com>" -logging =logPath D:\Password_Reminder_Scripts\Logging -testing -testRecipient me@domain.com
      D:\Password_Reminder_Scripts\PasswordChangeNotification.ps1 : Cannot process argument transformation on parameter 'status'. Cannot convert value 
      "System.String" to type "System.Management.Automation.SwitchParameter". Boolean parameters accept only Boolean values and numbers, such as 
      $True, $False, 1 or 0.
      At line:1 char:150
      + ... .com>" -logging =logPath D:\Password_Reminder_Scripts\Logging -testin ...
      +                              ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
          + CategoryInfo          : InvalidData: (:) [PasswordChangeNotification.ps1], ParameterBindingArgumentTransformationException
          + FullyQualifiedErrorId : ParameterArgumentTransformationError,PasswordChangeNotification.ps1
  • interval
    2 Posts | Last post January 16, 2020
    • Hello Robert,
      
      i have a question about your script. when i start it manually - everything works correctly. in report i see that the emails were sent correctly.
      
      but when i put it into task scheduler i see in the report: Skipped - interval
      
      what should be wrong? of course i am talking about the same person.
      
      MANUAL RUN:
      10	Tom	Tom	Li		30. 7. 2019 10:00:38	10	26. 1. 2020 10:00:38	OK
      
      
      TASK SCHEDULER:
      10	Tom	TOM	Li		30. 7. 2019 10:00:38	10	26. 1. 2020 10:00:38	Skipped - Interval
      
      Thank you
    • I already solved it, thanks :-)
  • Office 365
    3 Posts | Last post December 26, 2019
    • I am trying to setup my Scheduled Task but it seems that it does not like the credentials for O365.  I have tried using a domain admin account and my own but I can't get past the login during testing.  Any ideas?
    • Review this, https://www.youtube.com/watch?v=_-JHzG_LNvw&t=1s
    • The link don't work.
      Any solution ?
  • Task Scheduler disables this script
    2 Posts | Last post December 25, 2019
    • Hello
      I added this script to task scheduler as shown on youtube video. But task scheduler disables this script itself. I enable but 1 sec later it disable again.
      What is the problem? Can you help me?
      Have a nice day,
      Best Regards
    • Hi guy,
      This is normal, windows treats plan tasks like that. It starts and then stops the task, etc. Depending on the frequency. Trying to follow a complete loop by refreshing the window
  • Never installed a script before
    2 Posts | Last post December 05, 2019
    • Hello,
      
      I am currently assisting on building the company's infrastructure, and I was asked to look into sending an email out to our employees on letting them know that their password will expire soon. Where do I add this script and how do I add it without any issues? Thank you in advance.
    • Well id like to tell you how to do it without issues but i cannot.
      
      You can use the instructions in the youtube videos on how to setup and schedule the script.
  • New to Powershell Scripts
    2 Posts | Last post December 05, 2019
    • From where/which server do I need to run this script and do I need to run this script on daily basis?
    • Any system with access to AD and the SMTP Server.
  • Inline images not showing
    3 Posts | Last post December 05, 2019
    • Hello, Robert, thank you for your exptremely useful script. Works ar a charm, except I tried embedding inline images as shown here:
      
      https://www.youtube.com/watch?v=iwvQ5tPqgW0
      
      but I can't seem to be able to have the image to show.
      The attachment is there, the image's placeholder is there, but it doesn't show.
      
      I'm simply using
      $image1 = "\\fileserver\logo.png"
      In the body I have:
      <img src=""ser.png"" height=""102"" width=""215"">
      and then along the comman parameters:
      -attachments $image1
      
      Do you have any insight?
      
      Thank you ever so much
      
    • I actually have logo.png in the html, sorry for the typo, I just failed at generalising the filenames :)
    • it should be like this,
      
      $image1 = "\\fileserver\logo.png"
      
      <img src=""$image1"" height=""102"" width=""215"">
      
      -attachments $image1
  • Users are note receiving the emails after I run this script
    4 Posts | Last post November 15, 2019
    • Hello,
      
      Thank you for the great Script. I got an issue: I'm using office 365. By reading a previous post they mentioned that I needed to add -port 587 -UseSsl to smtp.office365.com.
      
      Can you please advise? 
      
      thank you !
      
      Script Loaded
      *** Settings Summary ***
      SMTP Server          : smtp.office365.com -port 587 -UseSsl
      Expire in Days       : 14
      From                 : XXX@domain.com
      Logging              : False
      Log Path             : 
      Testing              : False
      Test Recipient       : 
      Report Recipient     : 
      Intervals            : 
    • Secondly, Is it possible to configure in the script with these fields?
      SMTP Server          
      Expire in Days       
      From 
      
      To avoid to do this manually
    • We use office 365 also.  The setting we use is "domain-com.mail.protection.outlook.com"
      example "acme-com.mail.protection.outlook.com" If you have already authorized the IP to send mail through O365, and you SPF you should be all set. We had issues getting the direct send, and had to opt for option 2 in the link below.
      
      https://docs.microsoft.com/en-us/exchange/mail-flow-best-practices/how-to-set-up-a-multifunction-device-or-application-to-send-email-using-office-3
      
      The script has the fields
      SMTP Server          
      Expire in Days       
      From 
      Look in in the top section between lines 13 and 21
    • You need to add it on the Send-MailMessage line. not in the smtpserver address.
  • Different use for script
    1 Posts | Last post November 14, 2019
    • I would like to use this script in another manner, but not sure how to get it to populate for Expired accounts. Our contractor accounts expire every XX days. It would be nice if their was a sript that looked Account Expiration, and a Custom AD Attribute.
      
      The custom AD attribute would be the contractors manager, they would get a notice that their contractor's account is about to expire, and that they need to put a request into extend the account.
      
      Query for expiring account
      
      Get-ADUser -Filter 'enabled -eq $true' -Properties AccountExpirationDate | Select sAMAccountName, AccountExpirationDate
  • How to highlight Text in email
    5 Posts | Last post November 14, 2019
    • I am trying to use an html message and I am not getting the <mark> command to work
      I can use <h1> <h2> and <strong> tags, however, <mark> does not work? Should it?
      What am I missing? My HTML works otherwise. Below is snip of parts of the message format. This works as HTML, obliviously a few changes, but otherwise it is good.
      
      Example
      $body ="
      <font face=""verdana"">
             Dear $name,
      <P>  You are receiving this notice because
      <strong><mark>Section 2</strong></mark> Working over VPN\Traveling<br>
      <p>	Disconnect from VPN and then reconnect using your new password.<br>
      <br>
       <h1>    Password Reset Tool </h1>
      Login to <a href=""https://someURL/owa"">Password Reset Tool</a> Step for detail, Additional detail here.
      <br>
      <p>    Thanks,
      <<mark>Highlightme</mark>	 
          </P>" 
    • I just wanted to add to my earlier post... the example I gave shows <<mark>... I cannot edit my post, but it should read <mark>Highlightme</mark>	
    • Your mail client may not support <h> tags.
      
      Try editing the text using <font> instead.
      
      
    • H Tags work. The Highlight tag does not. 
      Office 365 \ Outlook client.
      
      
    • Sorry, I called it Highlight, but the tag that does not work is the <mark> tag.
1 - 10 of 537 Items