How to execute a PowerShell script upon successful AD user creation or modification using ADManager Plus

Last updated on:

Objective

To run a PowerShell script using ADManager Plus

Solution

ADManager Plus allows you to execute custom PowerShell scripts upon successful Active Directory (AD) user creation or modification.

Steps to add a custom PowerShell script to be executed upon successful user creation or modification:

  1. Logon to ADManager Plus and navigate to the Management tab.
  2. Under the User Management section, click on User Creation Templates.
  3. Click on Create New Template and enter a suitable Template Name and Description.
  4. Select the desired Domain.
  5. Click on the Custom Attributes tab.
  6. Select the Run custom script on successful user creation option.
  7. In the text field that appears below the Script Command, specify the location of your PowerShell script.
  8. Following are the accepted / supported formats for specifying the script location:
    1. cscript scr.vbs %userName%
    2. cscript scr.bat %userName%
    3. cscript scr.ps1 %userName%
    Note:

    The script file should be located only in the Scripts folder under ADManager Plus' installation folder.

  9. Click on Save.
  10. Click on Save Template.
  11. To use this template,
    1. In single user creation, select it using the Selected Template option.
    2. For bulk user creation, specify this template's name under the TemplateName header in the CSV file that contains the details for bulk user creation via ADManager Plus.
Note:

You can also run the custom script as a:

  1. VBScript using the cscript C:\dir1\scr.vbs%userName% format.
  2. Batch file using the scr.bat format (or scr.cmd format).

Ensure that the path to the script file should not contain spaces if you are using naming formats like %userName%". In case you wish to use spaces in the path name or script name, use the '~' symbol to indicate spaces, in order to avoid erroneous results.

For executing custom scripts upon successful user modification, click the User Modification templates in the AD Mgmt tab, and follow the steps mentioned above.