Skip to content

local_user_admin_toggle.ps1

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

local_user_admin_toggle.ps1

Adds or removes a local user from the Administrators group.

Overview

This script adds or removes a local user from the Administrators group. Idempotent operation that ensures the user's group membership aligns with the requested action.

Purpose

Adds or removes a local user from the Administrators group. Idempotent operation that ensures the user's group membership aligns with the requested action.

Prerequisites

  • Windows 10/11
  • Admin privileges required
  • Target user must exist locally

Configuration

Data Sources & Priority

  1. Hardcoded values (username, action)

Required Inputs

  • Username : The local user account to manage
  • Action : "add" or "remove"

Settings

  • Operates on built-in Administrators group
  • Validates user exists before operation

Behavior

  1. Validates user exists
  2. Checks current membership status
  3. Adds or removes from Administrators group
  4. Reports final status

Security Notes

  • No secrets in logs
  • Modifies local group membership

Exit Codes

  • 0: Success
  • 1: Failure

Example Output

[ INPUT VALIDATION ]
--------------------------------------------------------------
Username : john
Action   : add

[ OPERATION ]
--------------------------------------------------------------
User found: john
Current membership: Not a member
Adding to Administrators group...

[ RESULT ]
--------------------------------------------------------------
Status : Success
Action : User added to Administrators

[ SCRIPT COMPLETED ]
--------------------------------------------------------------

Version History

  • 2025-11-29 v1.0.0 Initial Style A implementation

Links

Clone this wiki locally