New-LocalUser
Use New-LocalUser to create a local user account on a Windows computer, set its password, and control expiry and password-change options.
Documentation: Microsoft Learn — new-localuser
Syntax
Try it
PowerShell example · browser support is limited.
Execution scope: The full example below requires PowerShell outside this browser. You can edit this runner to use the supported practice commands; unsupported syntax returns an explanation.
Examples
Create a user with a prompted password
Show reference output
Illustrative output · values vary by environment
Name Enabled Description ---- ------- ----------- svc-backup True Backup service account
Create a service account that never expires
Show reference output
Illustrative output · values vary by environment
Name Enabled Description ---- ------- ----------- svc-app True
Create the user and add it to Administrators
Show reference output
Illustrative output · values vary by environment
(user created, then added to Administrators)
Parameters
Parameter definitions:
-Name— The logon name of the new account.-Password— A SecureString password. Prompt with Read-Host -AsSecureString; never hard-code one.-FullName— The display name shown on the logon screen and in user lists.-Description— A note about what the account is for. Always fill this in for service accounts.-PasswordNeverExpires— The password never expires. Use only for service accounts, never for people.-AccountNeverExpires— The account itself never expires.-UserMayNotChangePassword— Prevents the user from changing their own password.-Disabled— Creates the account disabled, so it cannot log on until enabled.-NoPassword— Creates the account with no password. Only safe for accounts that never log on interactively.
Local accounts are not domain accounts
New-LocalUser creates an account on one computer only. It does not appear in Active Directory and cannot log on to other machines. For domain-wide accounts, use New-ADUser instead.
This cmdlet needs the Microsoft.PowerShell.LocalAccounts module and administrator rights, and it runs on Windows only. It is not available in PowerShell 7 on Linux or macOS, and on Windows it works in both Windows PowerShell 5.1 and PowerShell 7.
A password passed with ConvertTo-SecureString -AsPlainText -Force exists as plain text in your script or history. For a one-off interactive creation, prompt with Read-Host -AsSecureString. For automation, pull the password from a vault or a credential file, never from the script itself.
List local users with Get-LocalUser
Create a domain user with New-ADUser
Build secure passwords with ConvertTo-SecureString
Updated 25 October 2026. Browser outputs are fictional; check the installed module help for your environment.
Recap
New-LocalUser Use New-LocalUser to create a local user account on a Windows computer, set its password, and control expiry and password-change options.
Next: Get Itemproperty