# $cs.CustomInventory_RemoveInstance

> Removes a custom inventory instance with all its values, and the category when it has no instances left.

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

**CapaOne**

### Description

Removes a custom inventory instance with all its values, and the category when it has no instances left. Does nothing if the instance doesn't exist. Windows-only.

For how custom inventory is stored in categories, instances and values, see [$cs.CustomInventory_SetValue](/capainstaller/powerpacks/cs-custominventory-setvalue/).

:::note[Collected only by CapaOne]
The function works on any Windows device, also under CapaInstaller, and removes the data from the registry under `HKLM\SOFTWARE\CapaSystems\CapaOneAgent\CustomInventory`. Only the CapaOne agent collects that data, so the removal reaches CapaOne with the agent's next hardware inventory. On a device without the CapaOne agent, only the registry changes.
:::

### Syntax

$cs.CustomInventory_RemoveInstance(string category, string instance)

### Parameters

#### category (String)

Name of the category, for example `Installed Applications`. Names aren't case-sensitive. Can't be empty or longer than 255 characters, and can only contain letters, digits, spaces and `-`: see [Names](/capainstaller/powerpacks/cs-custominventory-setvalue/#names).

#### instance (String)

Name of the instance to remove. Pass `""` for the instance `default`, which a category with only one instance uses. Same rules as `category`.

### Return value

None. Throws an error if an argument isn't valid, for example an empty `category`.

### Example

**PowerShell**

Removing an application's instance during `Uninstall`:

```powershell
$cs.CustomInventory_RemoveInstance('Installed Applications', '7-Zip')
```

### Related functions

[$cs.CustomInventory_RemoveValue](/capainstaller/powerpacks/cs-custominventory-removevalue/) [$cs.CustomInventory_RemoveCategory](/capainstaller/powerpacks/cs-custominventory-removecategory/) [$cs.CustomInventory_GetInstanceNames](/capainstaller/powerpacks/cs-custominventory-getinstancenames/)
