-
Notifications
You must be signed in to change notification settings - Fork 5
local_user_admin_toggle.ps1
Corey Watson edited this page Dec 24, 2025
·
2 revisions
Adds or removes a local user from the Administrators group.
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.
Adds or removes a local user from the Administrators group. Idempotent operation that ensures the user's group membership aligns with the requested action.
- Windows 10/11
- Admin privileges required
- Target user must exist locally
- Hardcoded values (username, action)
- Username : The local user account to manage
- Action : "add" or "remove"
- Operates on built-in Administrators group
- Validates user exists before operation
- Validates user exists
- Checks current membership status
- Adds or removes from Administrators group
- Reports final status
- No secrets in logs
- Modifies local group membership
- 0: Success
- 1: Failure
[ 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 ]
--------------------------------------------------------------
- 2025-11-29 v1.0.0 Initial Style A implementation
- View Script Source
- Scripts - Back to script index