Uwaga
Dostęp do tej strony wymaga autoryzacji. Może spróbować zalogować się lub zmienić katalogi.
Dostęp do tej strony wymaga autoryzacji. Możesz spróbować zmienić katalogi.
W Configuration Manager, gdy menedżer odnajdywania danych (DDM) wykryje, że rekord odnajdywania danych (DDR) zawiera właściwość, która nie istnieje w klasie zasobów, właściwość jest dodawana do klasy zasobów. W zależności od typu danych nowej właściwości poprzednie wystąpienia zasobu będą zawierać zero lub pusty ciąg ("") dla wartości nowej właściwości. Podczas aktualizowania istniejącej klasy zasobów należy określić wszystkie właściwości klasy. Nie uwzględniaj jednak siedmiu właściwości tworzonych przez usługę DDM. Gdy DDM tworzy nową klasę zasobów, dodaje te dodatkowe właściwości do klasy:
Resourceid
AgentName
AgentSite
AgentTime
Name (Nazwa)
Resourcetype
SMSAssignedSite
Opis tych właściwości można znaleźć w temacie
SMS_R_System
. Oprócz tworzenia tych właściwości, DDM tworzy wystąpienieSMS_ResourceMap
dla nowej wartości ResourceType.
Aby dodać właściwości do istniejącego typu zasobu
Pobierz określone wystąpienie istniejącego zasobu.
Utwórz nowe wystąpienie
SMSResGen
klasy.Utwórz nową trasę DDR przy użyciu
NewDDR
metody .Dodaj właściwości do trasy DDR przy użyciu metod ADDPROP_.
Zapisz nową trasę DDR do pliku przy użyciu
DDRWrite
metody .
Przykład
Poniższy przykład tworzy trasę DDR, która dodaje OrganizationalUnit
właściwość do SMS_R_System
klasy . Następnie możesz użyć tej właściwości do tworzenia kolekcji na podstawie działów i odpowiedniego dystrybuowania oprogramowania. Jeśli Organizacja używa usługi Active Directory, możesz użyć zawartych w niej informacji, aby wypełnić właściwość OrganizationalUnit
.
W poniższym przykładzie przedstawiono właściwości klucza, nazwy i identyfikatora GUID używane do aktualizowania klasy zasobów systemowych.
Sub CreateDDRToAddNewPropertiesToAnExistingResourceType()
' Define variables.
Dim resourceID
Dim existingResource
Dim newDDR
Dim siteCode
Dim organizationalUnit
' Set variables.
resourceID = 5
siteCode = "TQ1"
organizationalUnit = "Test OU"
' Get a specific resource (client) object using the resourceID value.
Set existingResource = GetObject("winmgmts:root/sms/site_" & siteCode & ":SMS_R_System.ResourceID=" & resourceID & "")
' Load an instance of the SMSResGen.dll.
Set newDDR = CreateObject("SMSResGen.SMSResGen.1")
' Create a new DDR using the DDRNew method.
newDDR.DDRNew "System", "Department Discovery", siteCode
' Add properties to the new DDR using the DDRAdd methods.
newDDR.DDRAddInteger "Client", existingResource.Client, ADDPROP_NONE
newDDR.DDRAddString "Client Version", existingResource.ClientVersion, 15, ADDPROP_NONE
newDDR.DDRAddStringArray "IP Addresses", existingResource.IPAddresses, 64, ADDPROP_NONE
newDDR.DDRAddStringArray "IP Subnets", existingResource.IPSubnets, 64, ADDPROP_NONE
newDDR.DDRAddString "Last Logon User Domain", existingResource.LastLogonUserDomain, 64, ADDPROP_NONE
newDDR.DDRAddString "Last Logon User Name", existingResource.LastLogonUserName, 255, ADDPROP_NONE
newDDR.DDRAddStringArray "MAC Addresses", existingResource.MACAddresses, 64, ADDPROP_KEY
newDDR.DDRAddString "NetBIOS Name", existingResource.NetbiosName, 64, ADDPROP_NAME
newDDR.DDRAddString "Operating System Name and Version", existingResource.OperatingSystemNameandVersion, 64, ADDPROP_NONE
newDDR.DDRAddString "Resource Domain OR Workgroup", existingResource.ResourceDomainORWorkgroup, 64, ADDPROP_NONE
newDDR.DDRAddStringArray "Resource Names", existingResource.ResourceNames, 128, ADDPROP_NONE
newDDR.DDRAddStringArray "SMS Installed Sites", existingResource.SMSInstalledSites, 3, ADDPROP_NONE
newDDR.DDRAddString "SMS Unique Identifier", existingResource.SMSUniqueIdentifier, 64, ADDPROP_GUID OR ADDPROP_KEY
newDDR.DDRAddStringArray "System Roles", existingResource.SystemRoles, 32, ADDPROP_NONE
' The new property that is being added.
newDDR.DDRAddString "Organizational Unit", OrganizationalUnit, 64, ADDPROP_NONE
' Write new DDR to file.
newDDR.DDRWrite "NewDDR_AddToExistingResource.DDR"
wscript.echo "Created new DDR."
End Sub
public void CreateDDRToAddNewPropertiesToAnExistingResourceType(WqlConnectionManager connection)
{
try
{
// Define and set the required variables.
int resourceID = 5;
string siteCode = "TQ1";
string organizationalUnit = "Test OU";
// Get a specific resource (client) object using the resourceID value.
IResultObject existingResource = connection.GetInstance(@"SMS_R_SYSTEM.ResourceID='" + resourceID + "'");
// Create the SMSResGenClass instance.
SMSRSGENCTLLib.SMSResGen newDDR = new SMSRSGENCTLLib.SMSResGen();
// Create a new DDR using the DDRNew method.
newDDR.DDRNew("System", "Department Discovery", siteCode);
// Add properties to the new DDR using the DDRAddInteger, DDRAddString and DDRAddStringArray methods.
newDDR.DDRAddInteger("Client", existingResource["Client"].IntegerValue, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddString("Client Version",existingResource["ClientVersion"].StringValue, 15, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddStringArray("IP Addresses",existingResource["IPAddresses"].StringArrayValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddStringArray("IP Subnets", existingResource["IPSubnets"].StringArrayValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddString("Last Logon User Domain",existingResource["LastLogonUserDomain"].StringValue, 255, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddString("Last Logon User Name",existingResource["LastLogonUserName"].StringValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_KEY);
newDDR.DDRAddStringArray("MAC Addresses",existingResource["MACAddresses"].StringArrayValue, 32, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NAME);
newDDR.DDRAddString("NetBIOS Name",existingResource["NetbiosName"].StringValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddString("Operating System Name and Version",existingResource["OperatingSystemNameandVersion"].StringValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddStringArray("Resource Names",existingResource["ResourceNames"].StringArrayValue, 128, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddStringArray("SMS Installed Sites",existingResource["SMSInstalledSites"].StringArrayValue, 3, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
newDDR.DDRAddString("SMS Unique Identifier",existingResource["SMSUniqueIdentifier"].StringValue, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_GUID | SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_KEY);
newDDR.DDRAddStringArray("System Roles",existingResource["SystemRoles"].StringArrayValue, 32, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
// The new property that is being added.
newDDR.DDRAddString("Organizational Unit", organizationalUnit, 64, SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_ARRAY | SMSRSGENCTLLib.DDRPropertyFlagsEnum.ADDPROP_NONE);
// Write new DDR to file.
newDDR.DDRWrite("NewDDR_AddToExistingResource.DDR");
Console.WriteLine("Created new DDR.");
}
catch (SmsException ex)
{
Console.WriteLine("Failed to create DDR. Error: " + ex.Message);
throw;
}
}
Przykładowa metoda nie ma parametrów.
Kompilowanie kodu
Ważna
Te przykłady języków VBScript i C# wymagają odpowiednio smsrsgen.dll i smsrsgenctl.dll. Oba pliki są dołączone jako część zestawu SDK do pobrania Configuration Manager (w folderze "Redistributables").
Plik smsrsgenctl.dll jest 32-bitową biblioteką dll i musi być zarejestrowany w systemie, w który będzie uruchamiana aplikacja. Ponadto aplikacja korzystająca z smsrsgenctl.dll powinna zostać skompilowana jako aplikacja x86.
Niezawodne programowanie
Aby uzyskać więcej informacji na temat obsługi błędów, zobacz Informacje o błędach Configuration Manager.
zabezpieczenia .NET Framework
Aby uzyskać więcej informacji na temat zabezpieczania aplikacji Configuration Manager, zobacz Configuration Manager administracja oparta na rolach.