Skip to content
Menu

Break-Glass Local Admin - Create or Reset It

Creates a local administrator for emergency access with a random 20-character password, written only to a secure RMM custom field and never printed or logged.

Break-glass local admin - create or reset it is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Break-glass local admin - create or reset it. Tell other MSPs how it worked for you.

Write a Review

LanguagePowerShell
Runs onWindows 10, Windows 11, Windows Server 2016+; runs as SYSTEM
NeedsPowerShell 5.1, administrator rights, an RMM custom field (secure) to receive the password
Changes thingsChanges what it runs on

What It Does

The script makes sure a local administrator named AccountName exists, as the emergency way in when the domain, Entra ID or the usual admin account is unreachable. If the account is missing, it creates it with a random 20-character password, enables it, and adds it to the local Administrators group, found by its SID so it works in any language.

If the account exists and RotatePassword is false, the default, nothing changes. If this script created or reset it earlier on this PC, the run reports OK and only warns when the account is disabled or not an administrator. If the account exists for any other reason the run says SKIPPED. Accounts that Windows LAPS manages are skipped. If RotatePassword is true, it sets a new random password, enables the account and puts it back in Administrators if it was removed.

The password comes from the operating system's cryptographic random number generator and has upper case, lower case, digits and symbols. It is written to the RMM field before it is set on the account, so a failed field write changes nothing. The password is never printed. It is not in the output, the answer, the data rows, the change log or the exported file. It is written only to the RMM custom field named by ResultField.

NinjaOne, Datto RMM and Syncro are supported, and the field should be a secure field. If ResultField is not set, or the RMM is not one it can write to, it refuses before changing anything, and OutputFormat Answer is refused for the same reason. It never touches the built-in Administrator, domain accounts or other administrators, and a domain controller ends in ERROR.

Before You Run It

  • Create a secure custom field in your RMM first, and pass its name as ResultField.
  • Use set-local-admin-password for the built-in Administrator. This script does not touch it.
  • Check who can read that field in your RMM. It holds a working administrator password.
  • Run it with DryRun=true first to see whether it would create or only report on the account.

Type and Risk

  • Type: Action. It makes its change, checks the change worked and says what changed. It exits 0, or 2 when it could not do the job.
  • Risk: Low. Set DryRun=true, or run it with -WhatIf, to list every change without making any.
  • What it changes: Creates or resets a local user account, adds it to the local Administrators group, writes its password to the RMM custom field.
  • Restart: It never restarts the machine.
  • Typical run: Under 15 seconds.
  • Example answer: "Break-glass admin msp-breakglass created; password written to field BreakGlassPassword"
  • Tested before listing on Windows 11 with Windows PowerShell 5.1, run as SYSTEM, against its own test cases.

Inputs

Pass an input as an argument (-Name value), as an environment variable with the same name, which is how most RMMs pass script variables, or change its default in the param() block at the top of the script. An argument wins over an environment variable, which wins over the default.

  • AccountName: The account name, 1 to 20 letters, digits, dot, underscore or hyphen. Default msp-breakglass.
  • Description: The account description, up to 48 characters. Default "MSP break-glass administrator".
  • RotatePassword: true to set a new password on an account that already exists. Default false.
  • PasswordNeverExpires: true (default) so the break-glass password never expires; false to follow the PC's password policy.

Every script also takes DryRun, OutputFormat (Text, Answer, Json or Csv), ExportPath and ResultField, which writes the answer to an RMM custom field.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

new-local-admin-account.ps1 · 989 lines · 51.6 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.