local_user_admin_create.ps1 - limehawk/rmm-scripts GitHub Wiki
local_user_admin_create.ps1
Creates or updates a local administrator account with a cryptographically secure random password.
Overview
This script creates or updates a local administrator account with a cryptographically secure random password. If the account exists, it resets the password. If not, it creates the account and adds it to the Administrators group.
Purpose
Creates or updates a local administrator account with a cryptographically secure random password. If the account exists, resets the password. If not, creates the account and adds it to the Administrators group.
Prerequisites
- Windows 10/11
- Admin privileges required
- PowerShell 5.1+
Configuration
Data Sources & Priority
- Hardcoded values (username)
- RNG for password generation
Required Inputs
- AdminUsername : Username for the local admin account (default: sudohawk)
Settings
- Password length: 16 characters
- Password includes: uppercase, lowercase, numbers, special characters
- Account added to local Administrators group
Behavior
- Generates cryptographically secure random password
- Checks if user account exists
- If exists: resets password
- If not exists: creates account and adds to Administrators group
- Outputs password (for RMM custom field capture)
Security Notes
- Password generated using RNGCryptoServiceProvider
- Password output to console for RMM capture only
- Consider storing password securely in RMM custom fields
Exit Codes
- 0: Success
- 1: Failure
Example Output
[ INPUT VALIDATION ]
--------------------------------------------------------------
Admin Username : sudohawk
Password Length : 16
[ OPERATION ]
--------------------------------------------------------------
Checking for existing account...
Account does not exist, creating...
Account created successfully
Adding to Administrators group...
[ RESULT ]
--------------------------------------------------------------
Status : Success
Action : Created
Password : ****************
[ SCRIPT COMPLETED ]
--------------------------------------------------------------
Version History
- 2025-11-29 v1.0.0 Initial Style A implementation
Links
- View Script Source
- Scripts - Back to script index