PowerShell Genie

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.

Command 4 min read Windows PowerShell 5.1 · Windows only

Documentation: Microsoft Learn — new-localuser

Syntax

1PS> New-LocalUser [-Name] <String> [-Password <SecureString>] [-FullName <String>] [-Description <String>] [-AccountNeverExpires] [-PasswordNeverExpires] [-UserMayNotChangePassword] [-Disabled] [<CommonParameters>]

Try it

Windows PowerShell

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.

Interactive simulation · fictional data

Examples

Create a user with a prompted password

1PS> $pw = Read-Host -AsSecureString -Prompt 'Password' New-LocalUser -Name 'svc-backup' -Password $pw -Description 'Backup service account'
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

1PS> $pw = ConvertTo-SecureString 'TempPass123!' -AsPlainText -Force New-LocalUser -Name 'svc-app' -Password $pw -PasswordNeverExpires -AccountNeverExpires -UserMayNotChangePassword
Show reference output

Illustrative output · values vary by environment

Name     Enabled  Description
----     -------  -----------
svc-app   True

Create the user and add it to Administrators

1PS> New-LocalUser -Name 'deploy' -NoPassword Add-LocalGroupMember -Group 'Administrators' -Member 'deploy'
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.

Microsoft Learn — new-localuser

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
Genie guideNew-LocalUser

New-LocalUser creates local Windows accounts from PowerShell: set a secure password, add a full name and description, prevent password expiry, and add the account to a group. Requires administrator rights. The console below is pre-loaded — run it, then change a value and run it again.