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. I have now moved it to GitHub - https://github.com/titlerequired/public

 
 
 
 
 
4.6 Star
(153)
87,695 times
Add to favorites
Active Directory
7/2/2020
E-mail Twitter del.icio.us Digg Facebook
  • 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.
  • Non-Standard SMTP Port with 2.9 version of script?
    2 Posts | Last post November 05, 2019
    • I am trying to run the 2.9 version of the script.  I want to specify a non-standard SMTP port for my SMTP server.
      
      I don't see a parameter for SMTP port, nor do I see any other place in the script to configure this value.
      
      Anyone know how to do this?
    • You can edit the Send-MailMessage lines directly to change your SMTP port.
  • Running the script
    1 Posts | Last post October 30, 2019
    • Thanks Morn77!  Now I have another question; can I run it as test before I setup the schedule?  If so do I run it from the scripts folder with my parameters?
  • entering values part 2
    2 Posts | Last post October 30, 2019
    • I am using the new version of the script.  An example of what is happening is this:
      on the line where it asks for the $expiredays, I enter 15 after the comma but I get the error; Missing ')' parameter in the function list
      
    • Dont change anything in the script unless you want to point to one group (ou) and not all users
  • entering values
    2 Posts | Last post October 30, 2019
    • I am very new to PS scripting so excuse the simple question.  How do I enter the values for smtpServer, expiry days, and From email in the script so it won't prompt every time it runs.
      
      Tanks.
    • You dont write them in the script, you write them when you run the script..
      
      EXAMPLE 
       PasswordChangeNotification.ps1 -smtpServer mail.domain.com -expireInDays 21 -from "IT Support <support@domain.com>" -reportTo myaddress@domain.com
  • Small problem
    2 Posts | Last post October 29, 2019
    • Hi can someone help me understanding why my output looks like the below? 
      
      UserName	Name	EmailAddress	PasswordSet	DaysToExpire	ExpiresOn	SendMail
      
      Name, Name	Email@Email.dk   8/17/2019 14:00	-73	8/17/2019 14:00	OK
      
      But look at the password set and DaysToExpire and ExpiresOn?? Something is wrong... I'm using the group solution and not users...
      
    • Oh, I can see our password policy says MaxPasswordAge              : 00:00:00... 
      
      Could I change the script so it knows that our MaxPasswordAge is 90 days? or should I change the MaxPasswordAge on my domain?
11 - 20 of 542 Items