Create User in Powershell
Set the username and passwordPowershell
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
To elevate the user to local administrator, use the Add-LocalGroupMember cmdlet using the following formats for the account. To add multiple, separate with commas.
- Local Account
 
Add-LocalGroupMember -Group "Administrators" -Member "<username>"
- Microsoft Account
 
"MicrosoftAccount\<username@example.com>"
- Microsoft 365 Azure/Entra Account
 
"AzureAD\<username@example.com>"
- Active Directory Domain Account
 
"DOMAIN\<username>"
CMD
To create a user in the command prompt:
net user <username> <password> /fullname:"<Full Name>"
 
Add the user to the local administrators group:
net localgroup administrators <username> /add