Add/Edit/Delete Users on Windows

Add New User

net user /add <username> <password>
net user /add /domain <username> <password>

with SecureString Password

$Username = "John"
$Password = ConvertTo-SecureString "MyPassword123@" -AsPlainText -Force
$FullName = "John Doe"
$Description = "My new account"
$HomeDir = "C:\Users\John"

# Create new user
New-LocalUser -Name $Username -Password $Password -FullName $FullName -Description $Description -PasswordNeverExpires
# Add to "Users" local group
Add-LocalGroupMember -Group Users -Member $Username

Now reboot Windows computer and you can sign in the new account.


Add User to Local Group

# Add to the Administrators group.
net localgroup Administrators <username> /add

# Add to the WinRM group.
net localgroup "Remote Managment Users" <username> /add

# Add to the RDP group.
net localgroup "Remote Desktop Users" <username> /add

If we could add an user to the WinRM or RDP group, we can login WinRM or RDP with the user credential.


Change User Password

net user <username> <new-password>


Delete User

net user <username> /delete


Delete User From Local Group

# Delete from the Administrators group.
net localgroup Administrators <username> /delete

# Delete from the WinRM group.
net localgroup "Remote Management Users" <username> /delete