Create a local user account.
Syntax
New-LocalUser [-Name] String
[-AccountExpires DateTime] [-AccountNeverExpires] [-Description String]
[-FullName String] [-Password SecureString] [-PasswordNeverExpires]
[-UserMayNotChangePassword] [-Disabled] [-WhatIf] [-Confirm] [CommonParameters]
New-LocalUser [-Name] String
[-AccountExpires DateTime] [-AccountNeverExpires] [-Description String]
[-FullName String] [-NoPassword]
[-UserMayNotChangePassword] [-WhatIf] [-Confirm] [CommonParameters]
Key
-AccountExpires
Specify when the user account should expire.
To obtain a DateTime object, use Get-Date.
If you do not want the account to expire, specify the -AccountNeverExpires parameter.
-AccountNeverExpires
Set the account to not expire (boolean).
-Description
Set a comment for the user account. The maximum length is 48 characters.
-Disabled
Create the user account with login disabled.
-FullName
Change the full name of the user account. The full name differs from the user name of the user account.
-InputObject
The user account that this cmdlet changes. To obtain a user account, use Get-LocalUser.
-Name
The name of the user account to create.
If you create a local user account for the local system, the user name can contain up to 20 uppercase
characters or lowercase characters.
A user name cannot contain any of the following characters: " / \ [ ] : ; | = , + * ? < > @
A user name cannot consist only of periods . or spaces.
-NoPassword
Indicate that the user account does not have a password.
-Password SecureString
Specify a new password for the user account.
If the user account is connected to a Microsoft account, do not set a password.
You can use Read-Host -asSecureString, Get-Credential, or ConvertTo-SecureString to create a SecureString
object for the password.
If you omit the Password you will be prompted for a password to set.
A password can contain up to 127 characters.
-PasswordNeverExpires
Indicate whether the password expires (boolean).
-UserMayNotChangePassword
Indicate that the user cannot change the password on the user account.
-Confirm
Prompt for confirmation before executing the command.
-WhatIf
Describe what would happen if you executed the command without actually executing the command.
A user name cannot be identical to any other user name or group name on the computer.
A user name can contain up to 20 uppercase characters or lowercase characters.
This cmdlet does not generate any output.
Create a local user account:
PS C:\> New-LocalUser -Name "Kiosk64" -Description "Local Kiosk account." -NoPassword
Create a user account that has a password:
PS C:\> New-LocalUser "User64" -Password (Read-Host -AsSecureString) -FullName "Demo User" -Description "Temporary test account."
“Every new beginning comes from some other beginning’s end.” ~ Seneca
New-adUser - Create a new AD user account.
Get-LocalUser - Modify a local user account.
Set-LocalUser - Modify a local user account.
New-LocalGroup - Add a new local security group.