Skip to main content

Create User in Powershell

Set the username and password

The first command uses the Read-Host cmdlet to prompt you for a password. The command stores the password as a secure string in the $Password variable.

The second command creates a local user account and sets the new account's password to the secure string stored in $Password. The command specifies a user name, full name, and description for the user account.

$Password = Read-Host -AsSecureString
$params = @{
    Name        = '<username>'
    Password    = $Password
    FullName    = 'Full Name'
    Description = 'Description of this user.'
}
New-LocalUser @params