# $cs.CustomInventory_GetValue

> Reads a custom inventory value without its unit. Returns $null if the value, instance or category doesn't exist.

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

**CapaOne**

### Description

Reads a custom inventory value without its unit. Returns `$null` if the value, 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_GetValue(string category, string instance, string name)

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

#### name (String)

Name of the value, for example `City`. Can't be empty, and can only contain letters, digits, spaces and `-`: see [Names](/capainstaller/powerpacks/cs-custominventory-setvalue/#names). You can also read `Last Updated`, the date and time of the instance's last change.

### Return value

The value, without its unit, as the type it was written as:

| Stored value | Returned as |
|:--|:--|
| A string | String |
| An integer | Int32 for a `REG_DWORD`, Int64 for a `REG_QWORD` or an integer with a unit |
| `$true` or `$false` | Boolean |
| A decimal number | Decimal |
| An array of strings | String array |
| A date, also `Last Updated` | `DateTime`, in the device's local time |
| A text with the unit `locale` or `url` | String |

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

### Example

**PowerShell**

```powershell
$city = $cs.CustomInventory_GetValue('Office', '', 'City')
if ($null -eq $city) {
    $cs.Job_WriteLog("No office city in the custom inventory yet")
}
```

Reading a size written with the unit `bytes`, which comes back as a number of bytes:

```powershell
$size = $cs.CustomInventory_GetValue('Installed Applications', '7-Zip', 'Installer Size')
$cs.Job_WriteLog("7-Zip installer size: $([math]::Round($size / 1MB, 1)) MB")
```

Checking when an instance last changed:

```powershell
$lastUpdated = $cs.CustomInventory_GetValue('Installed Applications', '7-Zip', 'Last Updated')
$cs.Job_WriteLog("7-Zip custom inventory last changed $lastUpdated")
```

### Related functions

[$cs.CustomInventory_SetValue](/capainstaller/powerpacks/cs-custominventory-setvalue/) [$cs.CustomInventory_RemoveValue](/capainstaller/powerpacks/cs-custominventory-removevalue/) [$cs.CustomInventory_GetInstance](/capainstaller/powerpacks/cs-custominventory-getinstance/)
