AD Password Expiration Notification
Purpose
How it works
- The scheduled automation runs on every DC in the policy. Only the DC that holds the PDC Emulator role does the work. Other DCs clear their output fields and exit successfully, so each domain is processed once.
- It reads every enabled user and gets the expiry date from
msDS-UserPasswordExpiryTimeComputed. - For each user expiring within the window that isn't excluded:
- Has an email address: the user gets the email.
- No email address: the HelpDesk address gets an email (if one is set). Otherwise the user is counted as an issue.
- It writes a report to
cpvalAdPasswordExpiryReportand a count of problems tocpvalAdPasswordExpiryIssues. A condition alerts when the count is above 0. - A local state file (
%ProgramData%\_Automation\Script\AD-PasswordExpirationNotification\NotificationState.json) remembers who was emailed. Each user gets one email per password cycle, as the Automate monitor did. Optional extra reminders can be set withcpvalAdPasswordExpiryReminderDays, e.g.3,1.
Platform: NinjaOne
Key Capabilities
- Email User – This automation helps to email AD users whose password is about to expire.
Associated Content
Script
| Name | Purpose |
|---|---|
| AD - Password Expiration Notification | For every enabled user whose password expires within N days (default 7) the script will send email to them. It should be scheduled daily at 6 AM to the target group Is Primary Domain Controller (Built-in group). |
Custom Fields
| Name | Level | Type | Purpose |
|---|---|---|---|
| cPVAL AD Password Expiry Days | Organization, Location, Device | Integer | This custom field is set to determine the Notification window in days. |
| cPVAL AD Password Expiry Email Method | Organization, Location, Device | Drop-down | This custom field is set to register the email method for users whose passwords are about to expire within a specified number of days. |
| cPVAL AD Password Expiry Exclusions | Organization, Location, Device | Multi-line | Provide sAMAccountNames separated by commas or newlines to be excluded from the password expiration notification. * wildcard allowed, e.g., svc_*. |
| cPVAL AD Password Expiry Notification | Organization, Location, Device | Drop-Down | This custom field is required to be set to enable the AD Password Expiry Notification alerting. |
| cPVAL AD Password Expiry Reminder Days | Organization, Location, Device | Text | Optional extra reminders, e.g. 3,1. Blank means one email per cycle. |
| cPVAL AD Password Expiry Fallback Email | Organization, Location, Device | Text | Optional. Helpdesk/PSA mailbox(es) for users without an email address, separated by semicolons (;). |
| cPVAL AD Password Expiry Graph Client Secret | Organization, Location, Device | Secure | This is used in the Graph only. Secure fields are readable by automations only, up to 500 characters. |
| cPVAL AD Password Expiry Graph Client ID | Organization, Location, Device | Text | This custom field is required to set the ClientId for the Ninja organization in O365 so the Graph integration can send emails to AD users. |
| cPVAL AD Password Expiry Sender | Organization, Location, Device | Text | Required. Sending mailbox. SMTP also accepts IT Support email. |
| cPVAL AD Password Expiry Graph Tenant ID | Organization, Location, Device | Text | This custom field is required to be set with the O365 tenant ID when the Graph option is set in the custom field 'cpvalAdPasswordExpiryEmailMethod'. |
| cPVAL AD Password Expiry SMTP Password | Organization, Location, Device | Secure | This custom field is required to pass the SMTP password for the SMTP emailing method. |
| cPVAL AD Password Expiry SMTP Port | Organization, Location, Device | Text | This custom field is required to be set only when the custom field 'cpvalAdPasswordExpiryEmailMethod' is set to the SMTP option. STARTTLS. Port 465 (implicit TLS) is not supported. |
| cPVAL AD Password Expiry SMTP Server | Organization, Location, Device | Text | This custom field is required to be set only when the custom field 'cpvalAdPasswordExpiryEmailMethod' is set to the SMTP option. STARTTLS. Port 465 (implicit TLS) is not supported. |
| cPVAL AD Password Expiry SMTP Username | Organization, Location, Device | Text | This custom field is required to provide the SMTP server details only when the custom field 'cpvalAdPasswordExpiryEmailMethod' is set to the SMTP option. |
| cPVAL AD Password Expiry Issues | Device | Integer | Users who couldn't be notified + failed emails + script errors. 0 = healthy. |
| cPVAL AD Password Expiry Report | Device | WYSIWYG | This custom field stores the last-run summary, expiring user list, including their status in the html data (tabular format). |
Group
| Name | Type | Purpose |
|---|---|---|
Is Primary Domain Controller | Built-in group | This contains the Primary Domain Controller Windows server. |
Task
| Name | Type | Purpose |
|---|---|---|
| AD Password Expiration Notification | Task | This task is scheduled to run on the Windows Server Domain Controller (specifically to DC with Infrastructure role) to perform the AD user expiration alerting. |
Audit Report
| Name | Type | Purpose |
|---|---|---|
| AD Password Expiration Notification | Knowledge Article | This knowledge article shows the AD users information about the user password expiry and the email sent to them or not. |
Condition
| Name | Condition Type | Purpose |
|---|---|---|
| AD Password Expiration Notification | Custom field Condition | This condition is built to create ticket if the AD user password expiration email sent failed. |
Implementation
Step 1: Create the Custom Fields
Create the below custom fields:
- Custom field - cPVAL AD Password Expiry Days
- Custom field - cPVAL AD Password Expiry Email Method
- Custom field - cPVAL AD Password Expiry Exclusions
- Custom field - cPVAL AD Password Expiry Notification
- Custom field - cPVAL AD Password Expiry Reminder Days
- Custom field - cPVAL AD Password Expiry Fallback Email
- Custom field - cPVAL AD Password Expiry Graph Client Secret
- Custom field - cPVAL AD Password Expiry Graph Client ID
- Custom field - cPVAL AD Password Expiry Sender
- Custom field - cPVAL AD Password Expiry Graph Tenant ID
- Custom field - cPVAL AD Password Expiry SMTP Password
- Custom field - cPVAL AD Password Expiry SMTP Port
- Custom field - cPVAL AD Password Expiry SMTP Server
- Custom field - cPVAL AD Password Expiry SMTP Username
- Custom field - cPVAL AD Password Expiry Issues
- Custom field - cPVAL AD Password Expiry Report
Step 2: Create the Automation
Create the automation and set it to run as System.
Step 3: Create the Task
Step 4: Create the Condition
Create the condition and add it to the Windows Server Policy
Step 5: Action
- Set the values of the Custom field - cPVAL AD Password Expiry Email Method to either
GraphorSMTP. (Note: The graph method is recommended.) - Accordingly provide the Graph client id, tenant id and the Graph Secret key Custom field - cPVAL AD Password Expiry Graph Client Secret, Custom field - cPVAL AD Password Expiry Graph Client ID, and Custom field - cPVAL AD Password Expiry Graph Tenant ID.
- Enable the Task - AD Password Expiration Notification by implementing it to the built-in group
Is Primary Domain Controller. - For ticketing on email sent failed enable the Condition - AD Password Expiration Notification.
FAQ
Q: Can this automation will be set without setting the Email method?
Yes, just check the ReportOnly method in the Script - AD - Password Expiration Notification variable.
Changelog
2026-11-11
- Initial version of the document