Skip to content

$cs.CustomInventory_RemoveCategory

CapaOne

Removes a custom inventory category with all its instances and values. Does nothing if the category doesn’t exist. Windows-only.

For how custom inventory is stored in categories, instances and values, see $cs.CustomInventory_SetValue.

$cs.CustomInventory_RemoveCategory(string category)

Name of the category to remove, 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.

None. Throws an error if category isn’t valid.

Removing the category that the package’s install script wrote, during Uninstall:

Terminal window
$cs.CustomInventory_RemoveCategory('Contoso AppSuite')

Removing a category that no package writes any more, if it exists:

Terminal window
if ($cs.CustomInventory_GetCategoryNames() -contains 'Office Location') {
$cs.CustomInventory_RemoveCategory('Office Location')
$cs.Job_WriteLog("Removed the old 'Office Location' custom inventory")
}

$cs.CustomInventory_RemoveInstance $cs.CustomInventory_RemoveValue $cs.CustomInventory_GetCategoryNames