Skip to main content

Active Directory - Plugin User Account - CreateUpdate

Summary

This script will create or update a domain admin account to be used with the AD plugin with a random password. It will set the password for the AD plugin on the domain controller as well; in case of failure, it will attempt basic troubleshooting to fix the AD plugin issues.

Additionally, there is an option available in the script to set the password as the deployment and default password for the location. This option can be controlled by the system property AD_Plugin_Set_Location_Default_Password.

Intended Target: Domain Controllers detected in the Active Directory Domains plugin. The script is called by the CWM - Automate - Internal Monitor - Active Directory - ADPluginUser - Create/Update monitor as an autofix.

Notes

  • This script will no longer function on any end-of-life systems, including 2003 Servers, 2008 Servers, 2011 SBS Servers, and 2012 Servers (both regular and R2 editions). Manual management of AD Plugin User Accounts will be necessary for these machines.
  • The AD_Plugin_Username must be distinct and cannot match the name of any existing group or user, as Windows cannot create a new user if a group or user with the same name already exists on the computer/domain. The default username is ADPluginUser.

File Hash

File Path: C:/ProgramData/_Automation/Script/Set-DomainAdmin/Set-DomainAdmin.ps1
SHA256: 393870CF414220D4113EBD90A273666427A9A7C85441A46DFC51F3938EACAADD
MD5: A92D15A5A2B09A826134BA5DEBC6E8C5

Sample Run

Sample Run

Implementation

The implementation steps must be followed to import/update the script after 2023-08-02

For Updating the Current Script:

  • If this script is still in use - Take note of the values of the global variables Username, Title, SetLocationDefaultPassword, and MinimumPasswordLength before importing the new version of the script.
    Update Step

  • Import the replacement Monitor, Script, and alert template using the ProSync plugin.

  • If you correctly documented the global variables in the old script, you can deprecate the old script AND alert template.

  • Run the new script against any online computer with the Set_Environment parameter set to 1. Use the values stored from the Global Parameters in the first step for the rest of the user parameters.
    Run Step

  • The script creates the AD_Plugin_Set_Location_Default_Password property as well. Set this value to the desired value (1 or 0).

    • Default value is Disabled (0).

For New Implementation:

  • Import the New Monitor, Script, and alert template using the ProSync plugin.

  • Run the script against any online computer with the Set Environment parameter set to 1. Set the required values for the rest of the user parameters.
    New Implementation

  • The script creates the AD_Plugin_Set_Location_Default_Password property as well. Set this value to the desired value (1 or 0).

Notes:

  • The user parameters are required for the first run only (First run of the updated script).

  • The values set for the user parameters will be used to create system properties used by the script and the CWM - Automate - Internal Monitor - Active Directory - ADPluginUser - Create/Update monitor set.

  • If values are not provided to the user parameters for the first run of the script, the script and the monitor set will then use the default values.

    • Default Password Title: ADPluginUser
    • Default Username: ADPluginUser
    • Default Password Update Days: 60
    • Default Minimum Password Length: 16
  • The Domain Name will be added to the end of the password title for clients with multiple domains.
    e.g.,
    ADPluginUser - Domain.local
    ADPluginUser - Dmn.local

  • Apart from the system properties controlled by the user parameters, the script creates the AD_Plugin_Set_Location_Default_Password property as well. This property can be used to set the generated credentials as the location's default password.
    Use 1 and 0 to toggle setting the generated password as the default and deployment password of the Domain Controller's location. The default is 0. The property can be generated by the script with a default value of 0; any required changes should be made manually.
    Default Password

Dependencies

CWM - Automate - RMM+ Plugin Configuration

Variables

NameDescription
STATUSStatus returned by the monitor set, if the script is executed by the monitor set.
psoutOutput of the PowerShell script creating/updating the user.
ScriptLogContent of the log file generated by the script.
LabelStatus of the credentials in the AD Domains plugin post setting.
CommandCommand used to reset the AD Plugin on the computer.
StatusStatus of the credentials in the AD Domains plugin post troubleshooting.
MaximumPasswordLengthMaximum length to create the random password.

Global Variables

NameDefaultRequiredDescription
ScriptEngineEnableLogger0TrueDisabling the logging to hide the generated password from the script logs.

User Parameters

NameExampleRequiredDescription
Set_Environment1FalseRequired for the first run only to set the system properties used by the solution.
AD_Plugin_Password_TitleADPluginUserFalseTo set the value for the system property AD_Plugin_Password_Title during the first run of the script. The Set_Environment parameter must be set to 1 to use this parameter. Leaving it blank will set the default value for the system property.
AD_Plugin_UsernameADPluginUserFalseTo set the value for the system property AD_Plugin_Username during the first run of the script. The Set_Environment parameter must be set to 1 to use this parameter. Leaving it blank will set the default value for the system property.
AD_Plugin_Password_Update_Days60FalseTo set the value for the system property AD_Plugin_Password_Update_Days during the first run of the script. The Set_Environment parameter must be set to 1 to use this parameter. Leaving it blank will set the default value for the system property.
AD_Plugin_Password_Minimum_Length16FalseTo set the value for the system property AD_Plugin_Minimum_Password_Length during the first run of the script. The Set_Environment parameter must be set to 1 to use this parameter. Leaving it blank will set the default value for the system property.

Note: The user parameters can only be used to create the system properties. If required, changes to the system properties should be made manually from the Dashboard > Config > Configuration > Properties.

System Properties

NameExampleRequiredDescription
AD_Plugin_Password_TitleADPluginUserFalseTitle of the password entry to use to store the credentials for the Active Directory plugin. The solution will use the default title ADPluginUser if the system property is missing.
AD_Plugin_UsernameADPluginUserFalseUsername of the password entry to use to create the credentials for the Active Directory plugin. The solution will use the default username ADPluginUser if the system property is missing.
AD_Plugin_Password_Update_Days60FalseAge of the password in days. The solution will use the default age 60 days if the system property is missing.
AD_Plugin_Password_Minimum_Length16FalseMinimum length of the random password to generate for the AD Plugin user. The default value is 16.
AD_Plugin_Set_Location_Default_Password0False1 and 0 to toggle setting the generated password as the default and deployment password of the Domain Controller's location. The default is 0. The property can be generated by the script with a default value of 0; any required changes should be made manually.
AD_Plugin_Account_Make_Admin1False1 and 0 to toggle adding the user to the "domain admins" group. The default value is 1.

Output

  • Script Logs