local_user_admin_toggle.ps1 - limehawk/rmm-scripts GitHub Wiki
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
- 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
- Validates user exists
- Checks current membership status
- Adds or removes from Administrators group
- 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
- View Script Source
- Scripts - Back to script index