Category filter
Script to change admin user to non-admin user in Windows
A user belonging to the ‘Administrators’ group has complete and unrestricted access to the device. Suppose you want to revoke the administrator privileges of a user to prevent them from making system-wide changes. You can easily get it done by writing commands to remove the users from the ‘Administrators’ group and add them to the ‘Users’ group. These commands can be embedded in a script, and you can run it directly from Hexnode using the Execute Custom Scripts remote action.
Batch file script to change an admin user to a non-admin user
1 2 3 4 5 6 7 8 9 10 11 |
Rem Step 1: Add the user to the Users group. NET LOCALGROUP Users Username /ADD Rem Step 2: Remove the user from the Administrators group NET LOCALGROUP Administrators Username /DELETE Rem Step 3 (Optional): List the users belonging to Administrators or Users group NET LOCALGROUP Groupname |
PowerShell script to change an admin user to a non-admin user
1 2 3 4 5 6 7 8 9 10 11 |
#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): List the users belonging to Administrators or Users group Get-LocalGroupMember -Group “Groupname” |
Replace “Username” with the actual username and “Groupname” with the desired group name.