Search

How to create a local user in Windows Server using New-LocalUser PowerShell cmdlet

New-LocalUser PowerShell cmdlet can be used to create a new user in Windows Server 2025. The syntax of New-LocalUser PowerShell cmdlet is as shown below.


New-LocalUser [-AccountExpires <DateTime>] [-AccountNeverExpires] [-Description <String>] [-Disabled] [-FullName <String>] [-Name] <String> -Password <SecureString> [-PasswordNeverExpires] [-UserMayNotChangePassword] [-WhatIf] [-Confirm] [<CommonParameters>]

New–LocalUser PowerShell cmdlet is explained in below table.

Cmdlet or ParameterWhat is itDescription
New–LocalUserPowerShell cmdletPowerShell cmdlet to create a new local user
–AccountExpiresParameterDateTime object input to specify when the user account expires. A blank –AccountExpires parameter can be used to create a local account that does not expire.
–AccountNeverExpiresParameter–AccountNeverExpires parameter is used to specify that the new local account created does not expire.
–ConfirmParameter–Confirm parameter is used to prompt for confirmation before executing the PowerShell cmdlet.
–DescriptionParameter–Description parameter is used to provide a short description about the new local user.
–DisabledParameter–Disabled parameter is used to specify that the new local user account created will be in disabled state.
–FullNameParameter–FullName parameter is used to specify the full name of the new local user account.
–NameParameter–Name parameter is used to specify the user name of the new local user account.
–NoPasswordParameter–NoPassword parameter is used to specify that the new local user account does not have a password.
–PasswordParameter–Password parameter specifies a password for the user account as SecureString.
–PasswordNeverExpiresParameter–PasswordNeverExpires parameter is used to specify the password for the new local user will expire.
–UserMayNotChangePasswordParameter–UserMayNotChangePassword parameter is used to specify that the user cannot change the password on the user account.
–WhatIfParameter–WhatIf is used to see what will happen happen if the cmdlet runs.

 

Follow below steps to create a local user in Windows Server 2025, using New–LocalUser PowerShell cmdlet.

Step 01 – First, let as define a variable as SecureString to use as the –Password parameter of the New–LocalUser PowerShell cmdlet. Read-Host -AsSecureString PowerShell cmdlet can be used to read a line of input from the console securely and masked with asterisk character. Please refer the below PowerShell cmdlet.


PS C:\jajish>
PS C:\jajish> $passwdjajish = Read-Host -AsSecureString
**********

 

Now we have defined a variable as $passwdjajish to use as the password for the new local user. The value of the new password is stored in that variable. Please refer the following screenshot.

read-host-powershell-cmdlet-to-read-secure-input.jpg

 

Step 02 – Let as create a new local using the New–LocalUser PowerShell cmdlet as shown below. Please note that the input value for the -Password parameter is the variable ($passwdjajish) defined in the previous step.


PS C:\jajish>
PS C:\jajish>New-LocalUser -Name "jajish" -Password  $passwdjajish -FullName "Jajish Thomas" -Description "A user account for local login." -PasswordNeverExpires

Name   Enabled Description
----   ------- -----------
jajish True    A user account for local login.

 

We have created a new local user, with the user name "jajish". PasswordNeverExpires parameter of the New-LocalUser PowerShell cmdlet is used to specify that the password for the new user never expires. Please refer the following screenshot.

new-localuser-powershell-cmdlet-to-create-new-local-user.jpg

 

Written by Jajish Thomas.
Last updated on 1st August, 2024.

 

Related Tutorials
Introduction to Windows Server 2025
Minimum hardware requirements for Windows Server 2025
New features of Windows Server 2025
How to download Windows Server 2025 Preview iso file
How to install Windows Server 2025
Differences between Server Core and GUI (Desktop Experience)
Default GUI tools in Server Core
How to run PowerShell as administrator
How to run PowerShell as administrator in Server Core
How to find the PowerShell version in Server Core and Desktop experience
How to add Network icon to desktop in Windows Server 2025
How to add Computer (This PC) icon to desktop in Windows Server 2025
How to rename a computer using Windows Explorer
How to rename computer using "Rename-Computer" PowerShell Cmdlet
How to configure IPv4 Address in Windows Server 2025
How to configure IPv4 address in Windows Server 2025 using PowerShell Cmdlets
How to configure IPv6 Address in Windows Server 2025
How to configure IPv6 Address in Windows Server 2025 using PowerShell
What is MMC (Microsoft Management Console) and what are MMC snapin files
Add a snapin to MMC console
What are Roles and Features and difference between Roles and Features in Windows Server
Roles in Windows Server
Features in Windows Server
How to add Roles and Features in Windows Server
How to Remove Roles and Features in Windows Server
How to add Roles and Features using PowerShell
How to remove Roles and Features using PowerShell
Different types of computer hardware devices
What is a Driver Software
What is Device Manager and how to open Device Manager
What is Plug and Play (PnP)
How to scan for hardware changes using Device Manager and pnputil.exe
How to disable a device using Device Manager
How to disable a device using PowerShell Disable-PnpDevice Cmdlet
How to enable a device using PowerShell Enable-PnpDevice Cmdlet
How to update drivers using Device Manager
What is Driver Signing in Windows Operating Systems
What is Roll back of a driver and how to Roll Back a driver
How to uninstall a device using Device Manager
What are File attributes in Windows Operating Systems
attrib command in Windows
How to hide files and folders using Windows File Explorer
How to hide files and folders using attrib.exe command
How to view hidden files using Windows File Explorer
What are file name extensions
What are known file extensions and how to view known file extensions
How to associate a file name extension with an app
Hide or Show known file name extensions in Windows Server 2025
Hide or Show protected operating system files in Windows Server 2025
What are multi–user Operating Systems (OS) and multi–task Operating Systems (OS)
What are local user accounts and local groups in Windows Server
Different types of user accounts in Windows Server
How to create a local user in Windows Server
How to create a local user in Windows Server using New-LocalUser PowerShell cmdlet
How to force a local user to change password on next login
How to enable or disable a local user account
How to allow or prevent a local user to change password
What are Security Principals and SIDs
How to find SIDs of local user accounts