Add Manager email to Automatic User Provisioning
This article provides a PowerShell script snippet that can be used to automatically notify a manager when a new Active Directory user account is provisioned.
The script is designed for use in Cayosoft Administrator rules that create new users from external sources, and can be customized to fit your organization’s communication and approval process.
When executed as part of a new user provisioning rule, this script:
Looks up the manager of the newly created user
Generates a personalized email to the manager
Informs them about the new user’s account and credentials
Provides a link to request additional access for the new hire
This ensures the manager is aware of the new employee and can take any required follow-up steps immediately.
You can embed this PowerShell snippet in the "Notify Manager" section of the following provisioning rules:
How to configure notifications
In your selected provisioning rule:
Navigate to the Notify Manager section.
Enable the notification option.
In the Subject and Message fields, insert your custom PowerShell logic and dynamic values as needed.
Example:
Subject:
{"New Account Created for $($FoundObject.givenName) $($FoundObject.sn)"}Message:
{$managerName = "Manager"
if($FoundObject.manager -ne $Null){
$mgr = Get-ADUser -Identity $FoundObject.manager -Properties * -ErrorAction Ignore
if($mgr -ne $Null){
$managerName = $mgr.DisplayName
}
}
$header =
"
Dear $managerName<br/><br/>
New account has been created for $($FoundObject.givenName) $($FoundObject.sn).<br/><br/>
"
$body =
"
Login Name: $($FoundObject.sAMAccountName)<br/>
Password: $($FoundObject.Password)<br/><br/>
Email: $($FoundObject.mail)<br/><br/>
In order for any access to be given, submit the New User form located at http://intranet/InformationTechnology/helpdesk/Lists/User%20Profile%20Request/
"
$message = $header + $body
$message
}
Comments
0 comments
Please sign in to leave a comment.