Dela via


Konfigurera nätverksidentifiering

Du konfigurerar inställningarna för nätverksidentifiering i Configuration Manager genom att ändra nödvändiga inställningar för platskontrollfilen.

Så här konfigurerar du nätverksidentifiering

  1. Konfigurera en anslutning till SMS-providern.

  2. Upprätta en anslutning till avsnittet Nätverksidentifiering i platskontrollfilen med hjälp SMS_SCI_Component av klassen .

  3. Gå igenom matrisen med tillgängliga egenskaper och gör ändringar efter behov.

  4. Checka in ändringarna i platskontrollfilen.

  5. Upprätta en anslutning till avsnittet Nätverksidentifiering i platskontrollfilen med hjälp SMS_SCI_Configuration av klassen .

  6. Gå igenom matrisen med tillgängliga egenskaper och gör ändringar efter behov.

  7. Checka in ändringarna i platskontrollfilen.

Exempel

I följande exempel anges inställningarna för nätverksidentifiering med hjälp SMS_SCI_Component av klasserna och SMS_SCI_Configuration för att ansluta till platskontrollfilen och ändra egenskaper.

Obs!

Nätverksidentifiering är ovanligt eftersom det kräver att du anger både klassegenskaperna SMS_SCI_Component och SMS_SCI_Configuration för att aktivera komponenten.

Information om hur du anropar kodexempel finns i Anropa Configuration Manager kodfragment.


Sub ConfigureNetworkDiscoverySettings(swbemServices,         _  
                                      swbemContext,          _  
                                      siteCode,              _  
                                      enableDisableDiscovery)  

    ' Load site control file and get the SMS_SCI_Component, SMS_NETWORK_DISCOVERY section.  
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , swbemContext  

    ' Get the SMS_SCI_Component, SMS_NETWORK_DISCOVERY section of the site control file.   
    Query = "SELECT * FROM SMS_SCI_Component "       & _  
    "WHERE ComponentName = 'SMS_NETWORK_DISCOVERY' " & _  
    "AND SiteCode = '" & siteCode & "'"  

    ' Get the SMS_NETWORK_DISCOVERY properties.  
    Set SCIComponentSet = swbemServices.ExecQuery(Query, ,wbemFlagForwardOnly Or wbemFlagReturnImmediately, swbemContext)  

    ' Only one instance is returned from the query.  
    For Each SCIComponent In SCIComponentSet  

        ' Display the server name.  
        wscript.echo "Server: " & SCIComponent.Name        

        ' Loop through the array of embedded SMS_EmbeddedProperty instances.  
        For Each vProperty In SCIComponent.Props  

            ' Setting: Discovery Enabled  
            If vProperty.PropertyName = "Discovery Enabled" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value: " &  vProperty.Value1                 

                ' Modify the value.  
                vProperty.Value1 = enableDisableDiscovery  
                wscript.echo "New value:     " & enableDisableDiscovery  
            End If  

         Next  

         ' Update the component in your copy of the site control file. Get the path  
         ' to the updated object, which could be used later to retrieve the instance.  
          Set SCICompPath = SCIComponent.Put_(wbemChangeFlagUpdateOnly, swbemContext)  

    Next  

    ' Get the SMS_SCI_Configuration, SMS_NETWORK_DISCOVERY section of the site control file.                      
    Query = "SELECT * FROM SMS_SCI_Configuration "       & _  
    "WHERE ItemName = 'SMS_NETWORK_DISCOVERY' " & _  
    "AND SiteCode = '" & siteCode & "'"  

    ' Get the SMS_NETWORK_DISCOVERY properties.  
    Set SCIComponentSet = swbemServices.ExecQuery(Query, ,wbemFlagForwardOnly Or wbemFlagReturnImmediately, swbemContext)  

    ' Only one instance is returned from the query.  
    For Each SCIComponent In SCIComponentSet  

        ' Loop through the array of embedded SMS_EmbeddedProperty instances.  
        For Each vProperty In SCIComponent.Props  

            ' Setting: Discovery Enabled  
            If vProperty.PropertyName = "Discovery Enabled" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value: " &  vProperty.Value1                 

                ' Modify the value.  
                vProperty.Value1 = enableDisableDiscovery  
                wscript.echo "New value:     " & enableDisableDiscovery  
            End If  

         Next  

         ' Update the component in your copy of the site control file. Get the path  
         ' to the updated object, which could be used later to retrieve the instance.  
          Set SCICompPath = SCIComponent.Put_(wbemChangeFlagUpdateOnly, swbemContext)  

    Next  

    ' Commit the change to the actual site control file.  
    Set InParams = swbemServices.Get("SMS_SiteControlFile").Methods_("CommitSCF").InParameters.SpawnInstance_  
    InParams.SiteCode = siteCode  
    swbemServices.ExecMethod "SMS_SiteControlFile", "CommitSCF", InParams, , swbemContext  

End Sub  


public void ConfigureNetworkDiscoverySettings(WqlConnectionManager connection,  
                                              string siteCode,  
                                              string serverName,  
                                              string enableDisableDiscovery)  

{  
    try  
    {  
        // Connect to SMS_SCI_Component, SMS_NETWORK_DISCOVERY section of the site control file.  
        IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_Component.FileType=2,ItemType='Component',SiteCode='" + siteCode + "',ItemName='SMS_NETWORK_DISCOVERY|" + serverName + "'");  

        // Create temporary copy of the embedded properties.  
        Dictionary<string, IResultObject> embeddedProperties = siteDefinition.EmbeddedProperties;  

        // Enumerate through the embedded properties and makes changes as needed.  
        foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition.EmbeddedProperties)  
        {  
            // Setting: Discovery Enabled  
            if (kvp.Value.PropertyList["PropertyName"] == "Discovery Enabled")  
            {  
                Console.WriteLine();  
                Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
                Console.WriteLine("Current value: " + kvp.Value.PropertyList["Value1"]);  

                // Change value using the newDiscoveryEnabled value passed in.   
                embeddedProperties["Discovery Enabled"]["Value1"].StringValue = enableDisableDiscovery;  
                Console.WriteLine("New value    : " + enableDisableDiscovery);  
            }  
        }  

        // Store the settings that have changed.  
        siteDefinition.EmbeddedProperties = embeddedProperties;  

        // Save the settings.   
        siteDefinition.Put();  
    }  

    catch (SmsException ex)  
    {  
        Console.WriteLine();  
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);  
    }  

    try  
    {  
        // Connect to SMS_SCI_Configuration, SMS_NETWORK_DISCOVERY section of the site control file.  
        IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_Configuration.FileType=2,ItemType='Configuration',SiteCode='" + siteCode + "',ItemName='SMS_NETWORK_DISCOVERY'");  

        // Create temporary copy of the embedded properties.  
        Dictionary<string, IResultObject> embeddedProperties = siteDefinition.EmbeddedProperties;  

        // Enumerate through the embedded properties and makes changes as needed.  
        foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition.EmbeddedProperties)  
        {  
            // Setting: Discovery Enabled  
            if (kvp.Value.PropertyList["PropertyName"] == "Discovery Enabled")  
            {  
                Console.WriteLine();  
                Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
                Console.WriteLine("Current value: " + kvp.Value.PropertyList["Value1"]);  

                // Change value using the newDiscoveryEnabled value passed in.   
                embeddedProperties["Discovery Enabled"]["Value1"].StringValue = enableDisableDiscovery;  
                Console.WriteLine("New value    : " + enableDisableDiscovery);  
            }  
        }  

        // Store the settings that have changed.  
        siteDefinition.EmbeddedProperties = embeddedProperties;  

        //Save the settings.   
        siteDefinition.Put();  
    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);  
        throw;  
    }  
}  

Exempelmetoden har följande parametrar:

Parameter Typ Beskrivning
- connection
- swbemServices
-Hanterade: WqlConnectionManager
– VBScript: SWbemServices
En giltig anslutning till SMS-providern.
swbemContext -Vbscript: SWbemContext Ett giltigt kontextobjekt. Mer information finns i How to Add a Configuration Manager Context Qualifier by Using WMI (Lägga till en Configuration Manager kontextkvalificerare med hjälp av WMI).
siteCode -Hanterade: String
-Vbscript: String
Platskoden.
serverName -Hanterade: String
-Vbscript: String
Servernamnet.
enableDisableDiscovery -Hanterade: String
-Vbscript: String
Ett värde för att aktivera eller inaktivera identifieringsmetoden.

Inaktiverad- false

Aktiverat- true

Kompilera koden

Det här C#-exemplet kräver:

Namnområden

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Församlingen

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robust programmering

Mer information om felhantering finns i Om Configuration Manager fel.

.NET Framework Säkerhet

Mer information om hur du skyddar Configuration Manager program finns i Configuration Manager rollbaserad administration.

Se även

Om Configuration Manager-platskontrollfilen
Läsa och skriva till Configuration Manager platskontrollfil med hjälp av hanterad kod
Läsa och skriva till Configuration Manager platskontrollfil med hjälp av WMI
SMS_SCI_Component, serverns WMI-klass
Om schemanSå här Skapa du en schematoken