Skip to content

$cs.CustomInventory_GetInstance

CapaOne

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.

$cs.CustomInventory_GetInstance(string category, string instance)

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.

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

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

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

Logging every value of an instance:

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

$cs.CustomInventory_GetValue $cs.CustomInventory_GetInstanceNames $cs.CustomInventory_GetCategory $cs.CustomInventory_RemoveInstance