# $cs.UsrMgr_CreateLocalUser

> Creates a local user account. After creation, the function verifies that the account actually exists before returning.

Source: https://docs.capaone.com/capainstaller/powerpacks/cs-usrmgr-createlocaluser/  
Product: CapaInstaller — a separate CapaSystems product; do not apply this page to any other.

### Description

Creates a local user account. After creation, the function verifies that the account actually exists before returning. Throws an `ArgumentException` on bad arguments, or another exception if creation fails.

### Syntax

$cs.UsrMgr_CreateLocalUser(string userName, string fullName, string password, string description = "", bool passwordNeverExpire = true, bool userCannotChangePwd = false)

### Parameters

#### userName (String)

The name of the local user account to create.

#### fullName (String)

The full name of the user.

#### password (String)

The password for the account, in clear text.

#### description (String)

Description for the user account. Defaults to an empty string.

#### passwordNeverExpire (Boolean)

Sets whether the password never expires. Defaults to `$true`.

#### userCannotChangePwd (Boolean)

Sets whether the user is prevented from changing their own password. Defaults to `$false`.

### Return value

None.

### Example

**PowerShell**

Create a local user with the default settings (password never expires, user can change it):

```powershell
if (-not $cs.UsrMgr_ExistLocalUserAccount('capauser')) {
  $cs.Job_WriteLog("Creating local user capauser")
  $cs.UsrMgr_CreateLocalUser('capauser', 'Capa User', 'SuperSecretPassw0rd!')
}
```

Create a dedicated service account with a description and a never-expiring password, so scheduled tasks and services relying on it don't break after a password expiry policy kicks in:

```powershell
if (-not $cs.UsrMgr_ExistLocalUserAccount('svc_capaagent')) {
  $cs.Job_WriteLog("Creating service account svc_capaagent")
  $cs.UsrMgr_CreateLocalUser('svc_capaagent', 'Capa Agent Service Account', 'SuperSecretPassw0rd!', 'Runs the Capa Agent Windows service', $true)
}
```

Create a kiosk-style shared account where the logged-on user must not be able to change the password:

```powershell
if (-not $cs.UsrMgr_ExistLocalUserAccount('kioskuser')) {
  $cs.Job_WriteLog("Creating locked-down kiosk account kioskuser")
  $cs.UsrMgr_CreateLocalUser('kioskuser', 'Kiosk User', 'SuperSecretPassw0rd!', 'Shared kiosk account', $true, $true)
}
```

### Related functions

[$cs.UsrMgr_ExistLocalUserAccount](/capainstaller/powerpacks/cs-usrmgr-existlocaluseraccount/) [$cs.UsrMgr_DeleteLocalUserAccount](/capainstaller/powerpacks/cs-usrmgr-deletelocaluseraccount/) [$cs.UsrMgr_ChangePassword](/capainstaller/powerpacks/cs-usrmgr-changepassword/)
