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.

Note:


Supported Versions:

The scripts given below will be supported on the following versions:

  • Windows 10 v1607+ (Pro, Enterprise, Education)
  • Windows 11 (Pro, Enterprise, Education)

Disclaimer:


The sample scripts provided below are adapted from third-party open-source sites.

Batch script to change a non-admin user to an admin user

Replace the terms “Username” and “Groupname” with the actual names.

Batch script to change a non-admin Azure domain account user to an admin user

To grant admin rights:

To revoke admin rights:

Replace SAMName with the username of the Azure domain account.

PowerShell script to change a non-admin user to an admin user

Action History tab confirms the successful execution of the script to change a non-admin user to an admin user on Windows.

How to View Script Output in Hexnode

To review the execution results, navigate to the Action History tab of the specific device in your Hexnode UEM portal. Locate the script entry in the Subject column and click the Show Output button next to the status field to view the returned data.

Notes:

  • It is recommended to manually validate the script execution on a system before executing the action in bulk.

  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

Sample Script Repository