Skip to main content

Windows - Local Admin - Create/Update

Overview

Automates local administrator account management, password rotation, and NinjaRMM Custom Field synchronization.

This script creates a local admin account using values from custom fields or runtime variables provided during execution.

Dependencies

Sample Run

Scenario 1: Automated Maintenance (Standard Use)

Goal: Automatically manage the admin account defined in Custom Fields and rotate the password every 90 days.

Configuration:

Result:

Scenario 2: Manual Override (Forcing a Credential)

Goal: Force the password to "SpecificPass123!" for a specific user, regardless of what is stored in Custom Fields.

Configuration:

  • Script Variable "Local Admin Username" = "AdminUser"
  • Script Variable "Password" = "SpecificPass123!" Image3

Result:

  • The script ignores the "cPVAL Local Admin Username" field
  • It sets the machine password to "SpecificPass123!"
  • Because "Do Not Update Custom Fields" was not set, the script overwrites "cPVAL Local Admin Password" with "SpecificPass123!"

Scenario 3: Temporary Access (No Save)

Goal: Temporarily change the password for troubleshooting without overwriting the stored password in Ninja.

Configuration:

  • Script Variable "Local Admin Username" = "AdminUser"
  • Script Variable "Password" = "TempPass123!"
  • Script Variable "Do Not Update Custom Fields" = "True" Image4

Result:

  • The script sets the machine password to "TempPass123!"
  • The script does not update "cPVAL Local Admin Password Rotation Days"
  • Ninja continues to show the old password, allowing you to revert later or keep official records clean

Parameters

NameExampleAccepted ValuesRequiredDefaultTypeDescription
Local Admin UsernameAdminUserAny valid Windows usernameNoFrom Custom FieldStringOverride the username for creating the local admin account via runtime variable
PasswordSpecificPass123!Any valid password stringNoAuto-generatedStringOverride the password for the local admin account via runtime variable
Display NameLocal AdministratorAny display name stringNoMatches usernameStringDisplay name for the local admin account (runtime variable only)
Password Never ExpiresTrue/FalseTrue, FalseNoFalseBooleanSet the local admin password to never expire (runtime variable only)
Do Not Update Custom FieldsTrue/FalseTrue, FalseNoFalseBooleanPrevent writing data back to NinjaRMM custom fields

Custom Fields

NamePurpose
cPVAL Local Admin UsernameEnter the username for the local admin account to be created
cPVAL Local Admin PasswordStores the password for the local admin account (automatically updated by script)
cPVAL Local Admin Password Rotation DaysSet the number of days for automatic password rotation (0 or blank = no rotation)
cPVAL Local Admin Password Update DateTracks the last date a new password was set (automatically updated by script)
cPVAL Local Admin Default PasswordSet a default password to use during account creation instead of generating a random one
cPVAL Local Admin Display NameEnter the display name for the local admin account (defaults to username if blank)
cPVAL Local Admin Minimum Password LengthSet the minimum password length for auto-rotation (Default: 14 characters)
cPVAL Local Admin Maximum Password LengthSet the maximum password length for auto-rotation (Default: minimum + 5 characters)
cPVAL Local Admin Password Never ExpiresEnable to set the local admin password to never expire
cPVAL Local Admin Password Update DateSelect the operating system to enable the solution

Automation Setup/Import

Automation Configuration

Output

  • Activity Details
  • Custom Field