Pricing  Get Quote
 
 

PowerShell scripts to notify Active Directory domain users on account expiration

The account expiration notification PowerShell script provided here sends email reminders to Active Directory users about their expiring user accounts. ADSelfService Plus, an Active Directory self-service password management and single sign-on solution, also supports sending account expiration notification to AD users. Here is a comparison of AD account expiration notification using PowerShell and ADSelfService Plus.

PowerShell

Enter and run the following PowerShell script for password expiration notification for domain users whose accounts will be expiring in 31 days
$users = Search-ADAccount -UsersOnly -AccountExpiring -TimeSpan 31:0:0:0.0

ForEach($user in $users)
{
    $userobj = $user | Get-ADUser -Properties EmailAddress,AccountExpirationDate

    $options = @{
        'To' = $userobj.EmailAddress
        'From' = 'administrator@domain.org'
        'Subject' = "Account is Expiring on $($userobj.AccountExpirationDate)"
        'SMTPServer' = 'svr.domain.local'
        'Body' = "Account is Expiring on $($userobj.AccountExpirationDate)"
    }

    Send-MailMessage @options
}
 Copied
Click to copy entire script

ADSelfService Plus

  • Open the ADSelfService Plus admin portal.
  • Go to Configuration > Password Expiration Notification
  • In the Password/Account Expiration Notification section that opens, click on Add New Notifcation.
  • Use the Select Domain option to specify the domain whose users should receive the notifications.
  • Provide a Scheduler Name.
  • Set the Notification Type to Account Expiration Notification.
  • Use the Notify via option to specify the notification medium (mail, SMS, or push notification)
  • Select the Notification Frequency (Daily, Weekly or On Specific Days) and use the Schedule Time option to specify the date and time of the notification delivery.
  • Edit the Subject and the Message of the notification, if required.
  • Click on the Advanced option and in the pop-up window that opens, use the options for excluding disabled users or smart card users from receiving expiration notifications, and sending notification delivery status messages to users' managers or anyone with an admin account if necessary.
  • Click Save.
PowerShell scripts to notify Active Directory domain users on account expiration
PowerShell scripts to notify Active Directory domain users on account expiration

With ADSelfService Plus you are just a few clicks away from configuring account expiration reminders for domain users. In case of PowerShell, you need to create, debug and run scripts.

  • Notify users via mail, SMS and push notification:

    With ADSelfService Plus, you can choose between sending mail, SMS, and push notifications with just a click. In the above example, PowerShell is used to provide only email notifications for account expiration. PowerShell can also be used to send SMS and push notifications but this requires compiling an extremely extensive script.

  • Notify users' managers:

    In ADSelfService Plus notification delivery status emails can be sent to the users' managers and the organization's administrators. Also, you can choose to exclude disabled users and smart card users from receiving the notifications.

  • Customizable and powerful email notifications:

    Draft email notifications in HTML to grab the attention of users or send different messages on different days leading up to account expiration. Powershell does allow sending HTML formatted emails, but again the process can be quite lengthy.

  • GUI based configuration:

    Once an account expiration notification has been configured in ADSelfService Plus, it can be edited simply by selecting the notification to be edited and changing the values of the settings as required. With PowerShell, while making changes to the notification script, typos and other human errors are bound to occur .

Notify Active Directory users about account expiration.

  Get 30-day free trial.
  • Embark on your script-free AD Self-service password management with ADSelfService Plus.
  •  
  • By clicking 'Start your free trial now', you agree to processing of personal data according to the Privacy Policy.
  • Thank you for downloading!

    Your download should begin automatically in 15 seconds. If not, click here to download manually.

    Thank you for downloading!

    Your download should begin automatically in 15 seconds. If not, click here to download manually.

Related Resources

ADSelfService Plus trusted by

A single pane of glass for complete self service password management
Email Download Link