Creating Local Accounts in Powershell

Ok, creating a user account with Powershell- what’s interesting about this?

Well, let’s take a look:

$name = "serviceacct"
$password = Convertto-securestring "MagicPassword" -AsPlainText -Force
new-localuser -name $name -Password $password -PasswordNeverExpires
add-localgroupmember -Group "Administrators" -member $name

It’s noteworthy to point-out that you need to convert the password to a secure string. Otherwise, you’ll end up with a error like this:


A secure string is required for a password creation.

If you’re creating the account interactively, you can leave out -Password and you’ll be prompted for the password, where it is created as a secured string.


Here’s the link for additional switches and further info.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s