$cs.CustomInventory_GetValue
Description
Section titled “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.
Syntax
Section titled “Syntax”$cs.CustomInventory_GetValue(string category, string instance, string name)
Parameters
Section titled “Parameters”category (String)
Section titled “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.
instance (String)
Section titled “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)
Section titled “name (String)”Name of the value, for example City. Can’t be empty, and can only contain letters, digits, spaces and -: see Names. You can also read Last Updated, the date and time of the instance’s last change.
Return value
Section titled “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
Section titled “Example”$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:
$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:
$lastUpdated = $cs.CustomInventory_GetValue('Installed Applications', '7-Zip', 'Last Updated')$cs.Job_WriteLog("7-Zip custom inventory last changed $lastUpdated")Related functions
Section titled “Related functions”$cs.CustomInventory_SetValue $cs.CustomInventory_RemoveValue $cs.CustomInventory_GetInstance