Category filter
Script to change a non-admin user to an admin user in Windows
A user belonging to the ‘Users’ group does not have complete access to the device. Suppose you want to enable administrator privileges for a user. You can easily get it done by writing commands to remove the users from the ‘Users’ group and add them to the ‘Administrators’ group. These commands can be embedded in a script, and you can run them directly from Hexnode using the Execute Custom Scripts action.
Batch script to change a non-admin user to an admin user
1 2 3 4 5 6 7 8 9 10 11 |
Rem Step 1: Add the user to the Administrators group. NET LOCALGROUP Administrators Username /ADD Rem Step 2: Remove the user from the Users group NET LOCALGROUP Users Username /DELETE Rem Step 3 (Optional): List the users belonging to Administrators or Users group NET LOCALGROUP Groupname |
Batch script to change a non-admin Azure domain account user to an admin user
To grant admin rights:
123
@echo off net localgroup administrators "AzureAD\SAMName" /add echo.
To revoke admin rights:
123
@echo off net localgroup administrators "AzureAD\SAMName" /delete echo.
1 2 3 |
@echo off net localgroup administrators "AzureAD\SAMName" /add echo. |
To revoke admin rights:
123
@echo off net localgroup administrators "AzureAD\SAMName" /delete echo.
1 2 3 |
@echo off net localgroup administrators "AzureAD\SAMName" /delete echo. |
Replace SAMName with the username of the Azure domain account.
PowerShell script to change a non-admin user to an admin user
1 2 3 4 5 6 7 8 9 10 11 |
#Step 1: Add the user to the Administrators group Add-LocalGroupMember –Group “Administrators” -Member “Username” #Step 2: Remove the user from the Users group: Remove –LocalGroupMember –Group “Users” -Member “Username” #Step 3: (Optional): List the users belonging to Administrators or Users group Get-LocalGroupMember –Group “Groupname” |