Install-User

Installs a local user account.

Syntax

Install-User -UserName <String> -Password <String> [-Description <String>] [-FullName <String>] [-UserCannotChangePassword] [-PasswordExpires] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]
Install-User -Credential <PSCredential> [-Description <String>] [-FullName <String>] [-UserCannotChangePassword] [-PasswordExpires] [-PassThru] [-WhatIf] [-Confirm] [<CommonParameters>]

Description

Install-User creates a new local user account, or updates an existing local user account.

Returns the user if -PassThru switch is used. The object returned, an instance of System.DirectoryServices.AccountManagement.UserPrincipal, uses external resources, which means it can leak memory when garbage collected. When you're done using the user object you get, call its Dispose() method so its external resources are cleaned up properly.

The UserCannotChangePassword and PasswordExpires switches were added in Carbon 2.0.

Related Commands

Parameters

Name Type Description Required? Pipeline Input Default Value
UserName String

OBSOLETE. The UserName parameter will be removed in a future major version of Carbon. Use the Credential parameter instead.

true false
Password String

OBSOLETE. The Password parameter will be removed in a future major version of Carbon. Use the Credential parameter instead.

true false
Credential PSCredential

The user's credentials.

The Credential parameter was added in Carbon 2.0.

true false
Description String

A description of the user.

false false
FullName String

The full name of the user.

false false
UserCannotChangePassword SwitchParameter

Prevent the user from changing his password. New in Carbon 2.0.

false false False
PasswordExpires SwitchParameter

Set to true if the user's password should expire. New in Carbon 2.0.

false false False
PassThru SwitchParameter

Return the user. New in Carbon 2.0.

false false False
WhatIf SwitchParameter false false
Confirm SwitchParameter false false
CommonParameters This cmdlet supports common parameters. For more information type
Get-Help about_CommonParameters.

Return Values

System.DirectoryServices.AccountManagement.UserPrincipal.

EXAMPLE 1

Install-User -Credential $lukeCredentials -Description "Luke Skywalker's account."

Creates a new LSkywalker user account with the given password and description. Luke's password is set to never expire.

EXAMPLE 2

Install-User -Credential $lukeCredentials -UserCannotChangePassword -PasswordExpires

Demonstrates how to create an account for a user who cannot change his password and whose password will expire.