Category filter

Scripts to create users on Windows devices

Some corporate devices might be used by more than one employee. As a result, an administrator might have to create separate user accounts on each device. Here, we discuss one of the easiest ways to create users remotely. Hexnode lets admins deploy scripts to get the job done.

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

Create user

E.g., To create a user Josh,

Net user "Josh" "Josh123" /add

On deploying the above script, a new user account with username Josh will be added to the device, and the user can log in to the account using the password Josh123.

To create a user account with no password, do not provide any value for password in the above script.

E.g., Net user "Josh" "" /add

Change username

You can change the name of the created user account by running the script given below.

set “OldUser=old user name”

set “NewUser=new user name”

In the above command, replace the terms “old user name” and “new user name” with the actual names.

Script to change username remotely executed successfully from Hexnode.

PowerShell script

Create user

To create a user, you can run the script given below.

[string]$UserName = “username”,

[string]$PasswordPlain = “password”

In the above command, replace the terms “username” and “password” with the actual names. For example, to create a user “josh” with password “josh123”, then the command should be:

[string]$UserName = “josh”,

[string]$PasswordPlain = “josh123”

Script to create user in Windows returns the output in the Action History tab of Hexnode.

Change username

You can change the name of the created user account by running the script given below.

Replace ‘Administrator’ with the current name of the user and ‘NewName’ with the new name of the user, respectively.

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