Installs a local user account.
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>]
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.
Name | Type | Description | Required? | Pipeline Input | Default Value |
---|---|---|---|---|---|
UserName | String | OBSOLETE. The |
true | false | |
Password | String | OBSOLETE. The |
true | false | |
Credential | PSCredential | The user's credentials. The |
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 . |
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.
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.