Poznámka
Přístup k této stránce vyžaduje autorizaci. Můžete se zkusit přihlásit nebo změnit adresáře.
Přístup k této stránce vyžaduje autorizaci. Můžete zkusit změnit adresáře.
V Configuration Manager resetujete mezipaměť inventáře hardwaru tak, že se připojíte k oboru názvů agenta inventáře a odstraníte instanci stavu akce inventáře pro inventář hardwaru.
Resetování mezipaměti inventáře hardwaru
Připojte se k oboru názvů agenta inventáře (root\ccm\invagt).
Odstraňte instanci stavu akce inventáře pro inventář hardwaru ({00000000-0000-0000-0000-000000000001}).
Příklad
Následující příklad metody ukazuje, jak resetovat mezipaměť inventáře hardwaru připojením k oboru názvů agenta inventáře a odstraněním instance stavu akce inventáře pro inventář hardwaru.
Informace o volání ukázkového kódu najdete v tématu Volání metody třídy objektu Configuration Manager pomocí rozhraní WMI.
Sub ResetHardwareInventoryCache()
' Get a connection to the "root\ccm\invagt" namespace.
Dim locator
Set locator = CreateObject("WbemScripting.SWbemLocator")
Dim services
Set services = locator.ConnectServer( , "root\ccm\invagt")
' Delete the specified InventoryActionStatus instance.
services.Delete "InventoryActionStatus.InventoryActionID='{00000000-0000-0000-0000-000000000001}'"
' Display message.
wscript.echo "Reset Hardware Inventory cache."
End Sub
// How to Reset the Hardware Inventory Cache
public void ResetHardwareInventoryCache()
{
try
{
// Define the scope (namespace).
ManagementScope inventoryAgentScope = new ManagementScope(@"root\ccm\invagt");
// Load the class that you want to work with.
ManagementClass inventoryClass = new ManagementClass(inventoryAgentScope.Path.Path, "InventoryActionStatus", null);
// Query the class for the InventoryActionID object (create query, create searcher object, execute query).
ObjectQuery query = new ObjectQuery("SELECT * FROM InventoryActionStatus WHERE InventoryActionID = '{00000000-0000-0000-0000-000000000001}'");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(inventoryAgentScope, query);
ManagementObjectCollection queryResults = searcher.Get();
// Enumerate the collection to get to the result (there should only be one item returned from the query).
foreach (ManagementObject result in queryResults)
{
// Display message and delete the object.
Console.WriteLine("Resetting Hardware Inventory cache.");
result.Delete();
}
}
catch (System.Management.ManagementException ex)
{
Console.WriteLine("Failed to run action. Error: " + ex.Message);
throw;
}
}
Kompilace kódu
Tento příklad jazyka C# vyžaduje:
Obory názvů
System.management
Robustní programování
Další informace o zpracování chyb najdete v tématu Informace o chybách Configuration Manager.
Zabezpečení rozhraní .NET Framework
Další informace o zabezpečení Configuration Manager aplikací najdete v tématu Configuration Manager správa na základě rolí.
Viz taky
sada Configuration Manager Software Development Kit
Informace o inventáři Configuration Manager