Create a local user account.

      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]

       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.

       Set the account to not expire (boolean).

       Set a comment for the user account. The maximum length is 48 characters.

       Create the user account with login disabled.

       Change the full name of the user account. The full name differs from the user name of the user account.

       The user account that this cmdlet changes. To obtain a user account, use Get-LocalUser.

       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.

       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 -GetCredential, 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.

       Indicate whether the password expires (boolean).

       Indicate that the user cannot change the password on the user account.

       Prompt for confirmation before executing the command.

       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."

“Innovations that are guided by smallholder farmers, adapted to local circumstances, and sustainable for the economy and environment will be necessary to ensure food security in the future” ~ Bill Gates

Related PowerShell Cmdlets

New-adUser - Create a new AD user account.
Set-LocalUser - Modify a local user account.
New-LocalGroup - Add a new local security group.

Copyright © 1999-2024
Some rights reserved