Category filter
Script to change admin user to non-admin user in Windows
Administrator privilege grants complete and unrestricted access to a device, allowing the implementation of system-wide changes. These privileges cannot be granted to users without proper discretion. Removing a user from the Administrators group and adding them to the Users group in a Windows device, remotely, will revoke their admin privileges, making them a standard non-admin user. In this article, both Batch and PowerShell scripts are provided to change an admin user to a non-admin user. These scripts can be executed using the Execute Custom Script remote action from Hexnode UEM.
In both the scripts below, replace “Username” with the actual username of the admin user who must be made a standard user.
Batch file script to change an admin user to a non-admin user
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
@ECHO OFF REM --- User Demotion Commands (Silent Execution) --- NET LOCALGROUP Users "Username" /ADD >nul 2>&1 NET LOCALGROUP Administrators "Username" /DELETE >nul 2>&1 REM --- Output: List the current status of groups --- ECHO. ECHO --- Administrators Group Members (Post-Change) --- NET LOCALGROUP Administrators ECHO. ECHO --- Users Group Members (Post-Change) --- NET LOCALGROUP Users ECHO. ECHO Demotion process completed for Username. |
PowerShell script to change an admin user to a non-admin user
|
1 2 3 4 5 6 7 8 9 |
#Step 1: Add the user to the Users group Add-LocalGroupMember -Group “Users” -Member “Username” #Step 2: Remove the user from the Administrators group: Remove-LocalGroupMember -Group “Administrators” -Member “Username” #Step 3: (Optional) Verify the change Get-LocalGroupMember -Group “Administrators” Get-LocalGroupMember -Group “Users” |