Today I learned how to create a user account on Windows 10 using PowerShell. Let’s create a small exercise to demonstrate how can this be easily done.

Task: “Create a local user account named ‘localaccount’ with the password BlueHat. This new user should have admin privilege.”

First, launch the PowerShell (terminal?), by running as Administrator.

The password will be stored in a variable called $Password:

$Password = Read-Host -AsSecureString

Now we’re ready to create a new local account:

New-LocalUser -Name "localadmin" -Description "Optional Description Field" -Password $Password

Finally, we can add this new created account into the Administrators group to have admin privilege.

Add-LocalGroupMember -Group "Administrators" -Member "localadmin"

That’s it. Though it looks simple, I’m pretty sure I would not remember how to do this next week. Is there a command-line manual (man) on PowerShell terminal too?

As a side note, I’m planning to write more blog posts about PowerShell as it’s being used at my work place.