# $cs.CustomInventory_GetInstanceNames

> Returns the names of the instances in a custom inventory category. Returns an empty array if the category doesn't exist.

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

**CapaOne**

### Description

Returns the names of the instances in a custom inventory category. Returns an empty array if the category 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 reads the data in the registry under `HKLM\SOFTWARE\CapaSystems\CapaOneAgent\CustomInventory`. Only the CapaOne agent collects that data, with its hardware inventory. On a device without the CapaOne agent, the data stays in the registry.
:::

### Syntax

$cs.CustomInventory_GetInstanceNames(string category)

### 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).

### Return value

Array of instance names (`string[]`). A category with only one instance has the instance `default`. Empty array if the category doesn't exist. Throws an error if `category` isn't valid.

### Example

**PowerShell**

```powershell
$instances = $cs.CustomInventory_GetInstanceNames('Installed Applications')
$cs.Job_WriteLog("Applications in the custom inventory: $($instances -join ', ')")
```

Removing the instances of applications that are no longer installed:

```powershell
foreach ($instance in $cs.CustomInventory_GetInstanceNames('Installed Applications')) {
    if (-not (Test-Path "$env:ProgramFiles\$instance")) {
        $cs.CustomInventory_RemoveInstance('Installed Applications', $instance)
    }
}
```

### Related functions

[$cs.CustomInventory_GetInstance](/capainstaller/powerpacks/cs-custominventory-getinstance/) [$cs.CustomInventory_GetCategory](/capainstaller/powerpacks/cs-custominventory-getcategory/) [$cs.CustomInventory_GetCategoryNames](/capainstaller/powerpacks/cs-custominventory-getcategorynames/)
