# $cs.CustomInventory_GetInstance

> Returns all values of a custom inventory instance as an ordered dictionary. Returns $null if the instance or category doesn't exist.

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

**CapaOne**

### Description

Returns all values of a custom inventory instance, by name. Returns `$null` if the instance or 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_GetInstance(string category, string instance)

### Parameters

#### category (String)

Name of the category, for example `Office`. 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 in the category. Pass `""` for the instance `default`, which a category with only one instance uses. Same rules as `category`.

### Return value

Ordered dictionary (`System.Collections.Specialized.OrderedDictionary`) of value name to value, including `Last Updated`. Each value is returned without its unit, as [$cs.CustomInventory_GetValue](/capainstaller/powerpacks/cs-custominventory-getvalue/) returns it. Value names aren't case-sensitive.

`$null` if the instance or the category doesn't exist. Throws an error if an argument isn't valid, for example an empty `category`.

### Example

**PowerShell**

```powershell
$office = $cs.CustomInventory_GetInstance('Office', '')
if ($null -ne $office) {
    $cs.Job_WriteLog("Office: $($office['City']), floor $($office['Floor'])")
}
```

Logging every value of an instance:

```powershell
$values = $cs.CustomInventory_GetInstance('Installed Applications', '7-Zip')
foreach ($entry in $values.GetEnumerator()) {
    $cs.Job_WriteLog("$($entry.Key) = $($entry.Value)")
}
```

### Related functions

[$cs.CustomInventory_GetValue](/capainstaller/powerpacks/cs-custominventory-getvalue/) [$cs.CustomInventory_GetInstanceNames](/capainstaller/powerpacks/cs-custominventory-getinstancenames/) [$cs.CustomInventory_GetCategory](/capainstaller/powerpacks/cs-custominventory-getcategory/) [$cs.CustomInventory_RemoveInstance](/capainstaller/powerpacks/cs-custominventory-removeinstance/)
