Skip to content

local_user_admin_create.ps1

Corey Watson edited this page Dec 24, 2025 · 2 revisions

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

  1. Hardcoded values (username)
  2. 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

  1. Generates cryptographically secure random password
  2. Checks if user account exists
  3. If exists: resets password
  4. If not exists: creates account and adds to Administrators group
  5. 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

Clone this wiki locally