Create User in Powershell

Powershell

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.

Add-LocalGroupMember -Group "Administrators" -Member "<username>"

In the command above, replace <username> with the appropriate format below.

 

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


Revision #9
Created 2 September 2024 23:00:06 by B.B.B.Ben E. N. Agents
Updated 2 September 2024 23:48:21 by B.B.B.Ben E. N. Agents