# $cs.UsrMgr_ExistLocalUserAccount

> Checks whether a local user account exists. Accepts either a plain user name or a SID.

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

### Description

Checks whether a local user account exists. Accepts either a plain user name or a SID.

### Syntax

$cs.UsrMgr_ExistLocalUserAccount(string userName)

### Parameters

#### userName (String)

Name or SID of the local user account to check for.

### Return value

`[bool]` `$true` if the local user account exists, otherwise `$false`.

### Example

**PowerShell**

Gate a password change so it only runs when the account is present:

```powershell
if ($cs.UsrMgr_ExistLocalUserAccount('capauser')) {
  $cs.Job_WriteLog("capauser exists, updating password")
  $cs.UsrMgr_ChangePassword('capauser', 'SecretPassw0rd')
}
```

Gate account creation during install so the PowerPack can be re-run safely without recreating or resetting an existing account:

```powershell
if (-not $cs.UsrMgr_ExistLocalUserAccount('svc_capaagent')) {
  $cs.Job_WriteLog("svc_capaagent does not exist yet, creating it")
  $cs.UsrMgr_CreateLocalUser('svc_capaagent', 'Capa Agent Service Account', 'SuperSecretPassw0rd!')
} else {
  $cs.Job_WriteLog("svc_capaagent already exists, skipping creation")
}
```

### Related functions

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