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.