Для управления локальными пользователями и группами в Windows можно использовать встроенный PowerShell модуль Microsoft.PowerShell.LocalAccounts. С помощью этого модуля вы можете создать или удалить локального пользователя, создать новую группу безопасности и добавить в нее пользователей. Этот модуль доступен во всех версиях Windows, начиная с Windows Server 2016 и Windows 10. В предыдущих версиях Windows этот модуль устанавливается вместе с Windows Management Framework 5.1 при обновлении версии PowerShell.
Содержание:
- Создать нового локального пользователя с помощью PowerShell
- Управление локальными пользователями Windows из PowerShell
- Используем PowerShell для управления локальными группам
Полный список командлетов PowerShell в модуле LocalAccounts можно вывести так:
Get-Command -Module Microsoft.PowerShell.LocalAccounts
- Add-LocalGroupMember – добавить пользователя в локальную группу
- Disable-LocalUser – отключить локальную учетную запись
- Enable-LocalUser – включить учетную запись
- Get-LocalGroup – получить информацию о локальной группе
- Get-LocalGroupMember – вывести список пользователей в локальной группе
- Get-LocalUser – получить информацию о локальном пользователе
- New-LocalGroup – создать новую локальную группы
- New-LocalUser – создать нового пользователя
- Remove-LocalGroup – удалить группу
- Remove-LocalGroupMember – удалить члена из группы
- Remove-LocalUser – удалить пользователя
- Rename-LocalGroup – переименовать группу
- Rename-LocalUser – переименовать пользователя
- Set-LocalGroup – изменить группу
- Set-LocalUser – изменить пользователя
Рассмотрим несколько типовых задач по управлению локальными пользователями и группами на компьютере Windows при помощи PowerShell командлетов из модуля LocalAccounts.
Ранее для управления локальными пользователями и группами в Windows использовалась графическая оснастка Local Users and Groups Management (
lusrmgr.msc
) и команды
net user
,
net localgroup
.
Создать нового локального пользователя с помощью PowerShell
Чтобы быстро создать нового пользователя, выполните команду:
New-LocalUser -Name "TestUser1" -FullName "Test User" -Description "User for tests"
Укажите пароль для нового пользователя:
Если вы хотите использовать командлет New-LocalUser для автоматического создания новых локальных пользователей из скриптов PowerShell, пароль можно задать заранее в коде скрипта. Строку с паролем нужно преобразовать в формат Secure String:
$pass = ConvertTo-SecureString "WinitP@ss321!" -AsPlainText -Force
New-LocalUser -Name TestUser2 -Password $pass
Чтобы сразу добавить пользователя в группу локальных администраторов, выполните команду:
Add-LocalGroupMember -Group Administrators -Member TestUser2
При создании пользователя можно дополнительно использовать следующие параметры:
-
-AccountExpires
– дату действия учетной записи, при наступлении которого учетная запись будет автоматически отключена (по умолчанию командлет New-LocalUser создает бессрочную учетную запись) -
-AccountNeverExpires
-
-Disabled
– отключить учетную запись после создания -
-PasswordNeverExpires
– неограниченный срок действия пароля -
-UserMayNotChangePassword
– запретить пользователю менять свой пароль
Для создания нового пользователя в домене AD нужно использовать командлет New-ADUser.
Управление локальными пользователями Windows из PowerShell
Чтобы вывести список всех локальных пользователей Windows на текущем компьютере, выполните:
Get-LocalUser
Как вы видите, на компьютере имеется 7 локальных учетных записей, 4 из которых отключены (Enabled=False) (в том числе встроенный администратор Windows).
Чтобы вывести все свойства конкретной локальной учетной записи (аналог комадлета для получения информации о пользователях из AD — Get-ADUser), выполните:
Get-LocalUser -Name ‘root’ | Select-Object *
AccountExpires : Description : Enabled : True FullName : PasswordChangeableDate : 7/20/2022 12:17:04 PM PasswordExpires : UserMayChangePassword : True PasswordRequired : False PasswordLastSet : 7/20/2022 12:17:04 PM LastLogon : 5/15/2023 2:01:48 AM Name : root SID: S-1-5-21-1823742600-3125382138-2640950260-1001 PrincipalSource : Local ObjectClass : User
Обратите внимание на атрибут PrincipalSource. В нем указан тип аккаунта. Это может быть:
- Локальный пользователь Windows (PrincipalSource: Local)
- Учетные записи Microsoft (PrincipalSource: Microsoft Account)
- Учетные записи Azure AD (PrincipalSource: AzureAD)
Чтобы получить значение конкретного атрибута пользователя, например, время последней смены пароля, выполните:
Get-LocalUser -Name ‘root’ | Select-Object PasswordLastSet
Чтобы изменить пароль существующего пользователя, выполните команду:
Set-LocalUser -Name TestUser2 -Password $UserPassword –Verbose
Чтобы установить флаг «Срок действия пароля пользователя не истекает» («Password never expired»), выполните:
Set-LocalUser -Name TestUser2 –PasswordNeverExpires $True
Отключить учетную запись:
Disable-LocalUser -Name TestUser2
Включить пользователя:
Enable-LocalUser -Name TestUser2
Чтобы удалить локального пользователя, выполните:
Remove-LocalUser -Name TestUser2 -Verbose
Используем PowerShell для управления локальными группам
Теперь выведем список локальных групп на компьютере:
Get-LocalGroup
Создадим новую группу:
New-LocalGroup -Name 'RemoteSupport' -Description 'Remote Support Group'
Теперь добавим в новую группу несколько локальных пользователей и группу локальных администраторов:
Add-LocalGroupMember -Group 'RemoteSupport' -Member ('SIvanov','root', 'Administrators') –Verbose
Также вы можете добавить пользователя в группы с помощью следующего конвейера (в этом примере мы добавим пользователя в локальную группу, разрешающую ему удаленный доступ к рабочему столу через RDP):
Get-Localuser -Name TestUser2 | Add-LocalGroupMember -Group 'Remote Desktop Users'
Выведем список пользователей в локальной группе:
Get-LocalGroupMember -Group 'RemoteSupport'
В локальную группу могут быть добавлены не только локальные учетные записи (PrincipalSource – Local), но и доменные аккаунты (domain), учетные записи Microsoft (MicrosoftAccount) и аккаунты из Azure (AzureAD).
Чтобы добавить в локальную группу пользователя из Microsoft или AzureAD, используется такой синтаксис:
Add-LocalGroupMember -Group 'RemoteSupport' -Member ('MicrosoftAccount\[email protected]','AzureAD\[email protected]') –Verbose
Чтобы вывести список локальных групп, в которых состоит конкретный пользователь, выполните следующий скрипт:
foreach ($LocalGroup in Get-LocalGroup)
{
if (Get-LocalGroupMember $LocalGroup -Member 'sivanov' –ErrorAction SilentlyContinue)
{
$LocalGroup.Name
}
}
Чтобы удалить пользователя из группы, выполните:
Remove-LocalGroupMember -Group 'RemoteSupport' –Member 'testuser2'
Для управления локальными пользователями на удаленном компьютере нужно сначала подключится к нему через WinRM командлетами Invoke-Command или Enter-PSSession.
Например, нам нужно собрать список учетных записей в локальной группе на удаленных компьютерах:
$s = new-pssession -computer pc01,pc02,pc03
invoke-command -scriptblock {Get-LocalGroupMember -Group 'RemoteSupport'} -session $s -hidecomputername | select * -exclude RunspaceID | out-gridview -title "LocalAdmins"
When you need to create a local user in Windows 10 or 11 you can use the User Accounts control panel. But we can also use PowerShell to create a new local user. This way we can easily automate creating a local account on Windows devices.
To create a local user with PowerShell you will need to have administrator access to the computer and run PowerShell as admin (elevated). Otherwise, you won’t be able to create accounts.
In this article, I will explain how you can create a new localuser. At the end of the article, I have two PowerShell scripts that you can use to create a local user.
In this article
To create a new local user we are going to use the New-LocalUser
cmdlet in PowerShell. We have the option to set a password for the account or create an account without a password.
There are also a couple of other useful parameters that we can use:
Parameter | Description |
---|---|
-Name | Login name of the account – max 20 characters |
-Password | Password – supplied with a secure string |
-Description | Description of the account |
-AccountExpires | DateTime object when the account expires |
-AccountNeverExpires | Account does not expire |
-Disabled | Creates the account as disabled |
-FullName | The display name of the account |
-PasswordNeverExpires | Password does not expire |
-UserMayNotChangePassword | User can’t change the password |
So to quickly create a local user account with PowerShell we can do the following:
$password = Read-Host -AsSecureString New-LocalUser -Name "LazyUser" -Password $password -FullName "Lazy User" -Description "Test user"
Note
PowerShell 7.3.x throws an error “New-LocalUser: Could not load type ‘Microsoft.PowerShell.Telemetry.Internal.TelemetryAPI’” , you can solve it by first importing the localaccounts module with:
import-module microsoft.powershell.localaccounts -UseWindowsPowerShell
This small PowerShell script will require you to first enter the password, after which the user is created with the given password.
Providing the Password
As you can see this won’t allow you to run the script autonomous, because you will need to enter a password. This is also the challenge with creating local users, most of the time you want to supply the password in a secure way.
If you run the script remotely or under your own supervision then you could write the password inside a PowerShell script and convert it to a secure string. But keep in mind, anyone who opens the script is able to read the password!
# Username and Password $username = "LazyUser" $password = ConvertTo-SecureString "LazyAdminPwd123!" -AsPlainText -Force # Super strong plane text password here (yes this isn't secure at all) # Creating the user New-LocalUser -Name "$username" -Password $password -FullName "$username" -Description "Lazy Test user"
You could save this into a ps1 file and simply run it in an elevated PowerShell session.
Setting the Expired Date
By default, the new user account won’t expire, but with the New-LocalUser cmdlet, we can set an expiration date for the account. For the date we will need to use a PowerShell DateTime object:
$date = Get-Date -Year 2022 -Month 06 -Day 10 # Creating the user New-LocalUser -Name "$username" -Password $password -AccountExpires $date -FullName "$username" -Description "Lazy Test user"
Making user member of a group with Add-LocalGroupMember
After you have created the user you will need to make it a member of a local group. Without it, the user won’t be able to log on. To make the user member of a group we are going to use the Add-LocalGroupMember cmdlet.
The Add-LocalGroupMember only requires the group name and the member that you want to add:
Add-LocalGroupMember -Group Users -Member LazyUser
The cmdlet doesn’t give any output on success, only an error when the group name or member isn’t found.
You can also add multiple users to a local group with PowerShell. Simply comma separate the members in the cmdlet:
Add-LocalGroupMember -Group Users -Member "LazyUser", "LazyUser2"
Complete Script for new localuser in PowerShell
I have created two scripts that will help you with creating a local user account with PowerShell. In both scripts, I have added the option to write a log file. This log file is stored on a network share, allowing you to easily check if the creation is successful on the computer.
The first script has a password set in the script, so you can simply run the script on a computer. Keep in mind that you will need to have administrator access to create a local user account!
<# .SYNOPSIS Create local admin acc .DESCRIPTION Creates a local administrator account on de computer. Requires RunAs permissions to run .OUTPUTS none .NOTES Version: 1.0 Author: R. Mens - LazyAdmin.nl Creation Date: 25 march 2022 Purpose/Change: Initial script development #> # Configuration $username = "adminTest" # Administrator is built-in name $password = ConvertTo-SecureString "LazyAdminPwd123!" -AsPlainText -Force # Super strong plane text password here (yes this isn't secure at all) $logFile = "\\server\folder\log.txt" Function Write-Log { param( [Parameter(Mandatory = $true)][string] $message, [Parameter(Mandatory = $false)] [ValidateSet("INFO","WARN","ERROR")] [string] $level = "INFO" ) # Create timestamp $timestamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # Append content to log file Add-Content -Path $logFile -Value "$timestamp [$level] - $message" } Function Create-LocalAdmin { process { try { New-LocalUser "$username" -Password $password -FullName "$username" -Description "local admin" -ErrorAction stop Write-Log -message "$username local user crated" # Add new user to administrator group Add-LocalGroupMember -Group "Administrators" -Member "$username" -ErrorAction stop Write-Log -message "$username added to the local administrator group" }catch{ Write-log -message "Creating local account failed" -level "ERROR" } } } Write-Log -message "#########" Write-Log -message "$env:COMPUTERNAME - Create local admin account" Create-LocalAdmin Write-Log -message "#########"
The script will make the user member of the Administrators group in this case. You can of course change this to any other group. Make sure that you set the username, password, and logfile path in this first part of the script.
You can also download the complete script here from my Github repository.
Local User account script
The second script creates a local user account that is a member of the user’s groups. The difference with the first script is that this script will ask for the password.
<# .SYNOPSIS Create local user acc .DESCRIPTION Creates a local user account on de computer. Requires RunAs permissions to run .OUTPUTS none .NOTES Version: 1.0 Author: R. Mens - LazyAdmin.nl Creation Date: 25 march 2022 Purpose/Change: Initial script development #> # Configuration $username = "LazyTestUser" # UserName $fullName = "Lazy Test User" # Full name $logFile = "\\server\folder\log.txt" Function Write-Log { param( [Parameter(Mandatory = $true)][string] $message, [Parameter(Mandatory = $false)] [ValidateSet("INFO","WARN","ERROR")] [string] $level = "INFO" ) # Create timestamp $timestamp = (Get-Date).toString("yyyy/MM/dd HH:mm:ss") # Append content to log file Add-Content -Path $logFile -Value "$timestamp [$level] - $message" } Function Create-LocalUser { process { try { New-LocalUser "$username" -Password $password -FullName "$fullname" -Description "local user" -ErrorAction stop Write-Log -message "$username local user created" # Add new user to administrator group Add-LocalGroupMember -Group "Users" -Member "$username" -ErrorAction stop Write-Log -message "$username added to the local users group" }catch{ Write-log -message "Creating local account failed" -level "ERROR" } } } # Enter the password Write-Host "Enter the password for the local user account" -ForegroundColor Cyan $password = Read-Host -AsSecureString Write-Log -message "#########" Write-Log -message "$env:COMPUTERNAME - Create local user account" Create-LocalUser Write-Log -message "#########"
Again, you can download the complete script here from my Github repository.
Wrapping Up
The New-LocalUser should also be capable of creating a local account that is connected to a Microsoft account. But the username is still limited to 20 characters and doesn’t accept the @ symbol. So for now we are limited to local accounts only.
I hope this article helped you with creating a local user account with PowerShell. If you have any questions, just drop a comment below.
On Windows 10, you can create a local user account or Microsoft account that allows you to take advantage of additional benefits, such as settings syncing across devices and seamless integration to various Microsoft cloud services.
If you use Windows 10, you’re likely already utilizing an account connected to a Microsoft account. However, if you have to set up another account (in addition to using the Settings app and Command Prompt), you can create a new local user account from PowerShell.
This guide will teach you the steps to create and delete a new local user account using PowerShell on Windows 10.
- Create new local user account from PowerShell
- Delete new local user account from PowerShell
Create new local user account from PowerShell
To create a standard or administrator local account with PowerShell, use these steps:
-
Open Start on Windows 10.
-
Search for PowerShell, right-click the top result, and select the Run as administrator option.
-
Type the following command to temporarily store the password in a secure string inside the “$Password” variable and press Enter:
$Password = Read-Host -AsSecureString
-
Type the password for the new Windows 10 account and press Enter.
-
Type the following command to create the new account with PowerShell and press Enter:
New-LocalUser "NEW_ACCOUNT_NAME" -Password $Password -FullName "USER_FULL_NAME" -Description "DESCRIPTION"
In the command, change NEW_ACCOUNT_NAME for the account name and USER_FULL_NAME for the user’s full name. Also, replace DESCRIPTION with the description you want to use for the account.
-
Type the following command to add the Windows 10 account to the correct user group and press Enter:
Add-LocalGroupMember -Group "Administrators" -Member "NEW_ACCOUNT_NAME"
In the command, make sure to change NEW_ACCOUNT_NAME for the account name. In the above command, we add the new account to the Administrators group, which gives the user full access to the computer. However, if you want the user to have limited access, you can add the account to the Users group, making it a “Standard User.”
Once you complete the steps, the new account will be set up on the device with full access using administrative privileges. Of course, this is unless you added the account to the “Users” group, in which case the account will be a limited standard account.
Connect account to Microsoft
Using PowerShell should also be possible to create a user account connected to a Microsoft account with this command: New-LocalUser -Name "MicrosoftAccount\[email protected]" -Description "Microsoft account description"
. However, a bug still returns “New-LocalUser: Cannot validate argument on parameter ‘Name.’ The character length of the 36 arguments is too long. Shorten the character length of the argument so it is fewer than or equal to “20” characters, and then try the command again” message. As a result, the easiest way to get around this problem is to create a local account and then use the Settings app to link it with a Microsoft account.
To link a local account with a Microsoft account, use these steps:
-
Open Settings.
-
Click on Accounts.
-
Click on Your Info.
-
Click the “Sign in with your Microsoft account instead” option.
-
Continue with the on-screen directions to connect your account to a Microsoft account.
After you complete the steps, the new account will be connected to the Microsoft account you specified.
Delete new local user account from PowerShell
To delete an account with PowerShell on Windows 10, use these steps:
-
Open Start.
-
Search for Windows PowerShell, right-click the top result, and select the Run as administrator option.
-
Type the following command to delete the user account and press Enter:
Remove-LocalUser -Name "USER_ACCOUNT_NAME"
In the command, change USER_ACCOUNT_NAME with the account name you want to remove.
After you complete the steps, the account will be deleted from the computer. However, the user account data will remain. If you want to delete both account and data, the easiest way to delete it is using the “Accounts” page from the Settings app.
Why You Can Trust Pureinfotech
The author combines expert insights with user-centric guidance, rigorously researching and testing to ensure you receive trustworthy, easy-to-follow tech guides. Review the publishing process.
Last Updated :
30 Dec, 2024
Setting up a new user account in Windows 10 is essential for enhancing user experience and ensuring that your Windows 10 is running safely and securely. You can create a new user account for any Guest, Family member, Children etc. in just a few steps using different methods.
Create a New User Account in Windows 10 – 4 Methods
In this guide, we will provide step-by-step instructions on creating a new user in Windows 10, ensuring a smooth and efficient setup process.
Method 1: Using Windows Settings
This is a very common method to set up a new user account in Windows 10 PC. Let’s check the steps down below to understand how to perform this method seamlessly.
Step 1: Press Win + I to access Windows Settings
Alternatively you can click on the Start menu and click the Settings icon in the lower left corner.
Win + I > Settings
Step 2: Navigate to Family & Other Users from Accounts Settings
Now in the settings window, click on the Accounts icon (most preferably below Devices)
Accounts Settings
Step 3: Navigate to Family & other users to Set up a New Account
Now click on Family & other users > Add someone else to this PC
Family and other users.
Step 4: Finish the Account Setup Process
Once you click on Add someone else to this PC, you will have option to do the following:
- Create a new user account using Microsoft Account
Using Microsoft account
- Create a Local account without using Microsoft Account
Create account without Microsoft account
Once, you click on this, you’ll get a new pop-up something like this:
Setup new account
Follow the on-screen instructions to complete this action.
Method 2: Using the Control Panel
If you face any challenge while performing the above method, you can proceed to set up a new user account using Windows 10 Control Panel. Here’s how you can set it up:
Step 1: Go to Start and Navigate to the Control Panel
Click on Start Menu and type “Control Panel” in the search bar, or press Win + R to open “Run dialog box” and type Control Panel and hit the Enter button to proceed.
Start > Control Panel
Step 2: Navigate to User Accounts under Control Panel Settings
Go to User Accounts and then navigate to “Manage another account”
Manage another account
Step 3: Click on Add a new user to Set up a New User Account
Once you enter “manage another account” click on “Add a new user in PC Settings”
Add a new user in PC settings
Step 4: Finish the New User Account Set up
Follow the on-screen instructions to setup a new user account
Complete the account Setup
Method 3: Using the Command Prompt
If you’re a tech-savvy user and looking for a technical method to create a new account then this method is for you. Let’s see how to set up a new user account using CMD.
Step 1: Press Win + R and type “Command Prompt”
You can access command prompt using different methods:
- Press Win + R and type “CMD” or command prompt in the Run dialog box and hit the Enter button
- You can press Win + X and select Command Prompt
- Alternatively Go to Start Menu and type Command Prompt and hit the enter button
Note: Open Command prompt as “Administrator” only
cmd as admin
Step 2: Run net user Command to Setup the account creation
Now, type the following command and press enter:
net user Username Password /add
Run net user command
Your new account set up will get completed and you can switch users by pressing Ctrl + Alt+ Delete to check and navigate to the other user.
Method 4: Using PowerShell
Windows PowerShell also allows administrator to set up a new user account in Windows 10 by running New-LocalUser command. Here’s how you can perform:
Step 1: Press Win + X and select PowerShell (as admin)
You can also navigate to Start menu and type “PowerShell” and click “Run as admin” to start this action
Windows PowerShell as admin
Step 2: Run New-LocalUser Command to Setup the account creation
Now, type the following command and press enter:
New-LocalUser -Name "Username" -Password (ConvertTo-SecureString "Password" -AsPlainText -Force) -AccountNeverExpires
Account Setup
Note: Your new account set up will get completed and you can switch users by pressing Ctrl + Alt+ Delete to check and navigate to the other user.
Alternate Method: Local Users & Groups
Note: This method can only work on Windows 10 pro, Enterprise, and Education EDT.
Steps to create a new user account:
- Press Win + R and type “lusrmgr.msc and hit ENTER
- Navigate to Local Users and Groups > Users (right-click) > New User
- Fill out all the required details (username, password, etc.)
- Click on “Create” to complete the setup.
Conclusion
Adding or Creating a new user account in Windows 10 is a simple process that enhances the user experience by allowing personalized settings and files for each individual. You can use the Settings app, Control Panel and even PowerShell method to setup a new user in Windows 10.
Just ensure to update and manage user accounts on time so that each user has a secure and customized environment.
Windows 10 allows you to create a new user account where you can get additional benefits like effortless integration to different Microsoft cloud services, syncing across devices, and others. In order to get these benefits, you need to set up a new user account.
The good thing is that you can create a new users account With PowerShell on Windows 10. Here in this article, we will show you the way to create a new user account with PowerShell on Windows 10.
In order to create a new user account, create a local account first and then connect it with Microsoft account. Follow the below instructions to set up a new user account using PowerShell.
- Right-click on the Windows icon and choose Windows PowerShell (Admin) from the menu.
- Confirm Yes when UAC prompts.
- In the PowerShell window, type the command given below to temporarily store the password inside the $Password variable and hit Enter.
$Password = Read-Host -AsSecureString
- Now type the password you want and hit Enter.
- In the elevated window, type the command given below to create the new account and hit enter.
New-LocalUser "NEW_ACCOUNT_NAME" -Password $Password -FullName "USER_FULL_NAME" -Description "Description of this account."
Note: Substitute the NEW_ACCOUNT_NAME with the user name and USER_FULL_NAME with the full user name.
- Type the command given below to create an Administrator account and Hit Enter.
Add-LocalGroupMember -Group "Administrators" -Member "NEW_ACCOUNT_NAME"
Note: Substitute the NEW_ACCOUNT_NAME with the user’s name. This command is for creating an Administrator account. It allows the new user to have full access to the device. In the case when you want to provide limited access to the new users, substitute the Administrators group with the Users group. This will create Local user accounts.
How To Disable Command Prompt on Windows 11/10
Connect your newly created account to a Microsoft account
Now that you have created a new user account using PowerShell, you may add a Microsoft account to it as well. We strongly suggest doing this because you can never retrieve back the lost data when you suddenly forget the local user account passkey.
However, even if you forget your passkey when connected through a Microsoft, you can readily reset your password by clicking on – “I forgot my password“.
Follow the below instructions on how to connect your Microsoft account to the newly created user profile on your Windows PC.
- Press Windows + I to launch Settings.
- Go to Accounts, and click Your info on the right pane.
- Here, you can see the Sign in with your Microsoft account instead option.
Well, click on this link and do as you asked while the system is adding your Microsoft account to this PC. After this is over, you will see your previous account linked to a Microsoft account.
Always Run Command Prompt, PowerShell, and Terminal as Administrator
How to delete a new local user account with Powershell
Assuming you did create a new user account, there’s no use for your previous user profile. You may either delete your old profiles or keep them as long as you want. The below instructions will guide you on how to delete a new user or an existing user account from your Windows PC.
- Press Win + X, and select Windows PowerShell (Admin).
Note: Several users change this default configuration and add Command Prompt in place of PowerShell. If you have changed it as well, you may bring back the PowerShell from the taskbar settings under Personalization.
- The UAC window might prompt next, hit yes to authorize opening Windows PowerShell.
- When the PowerShell opens up, type the command given below and press Enter.
Remove-LocalUser -Name "USER_ACCOUNT_NAME"
Note: Don’t forget to substitute the USER_ACCOUNT_NAME with the new account name. In the case when you use the wrong name, the system will delete the incorrect account.
Once you complete the above steps, the new user account will be deleted from your system.