Observação
O acesso a essa página exige autorização. Você pode tentar entrar ou alterar diretórios.
O acesso a essa página exige autorização. Você pode tentar alterar os diretórios.
Pode configurar as definições de Deteção de Rede, no Configuration Manager, ao modificar as definições de ficheiro de controlo de site necessárias.
Para configurar a Deteção de Rede
Configure uma ligação ao Fornecedor de SMS.
Efetue uma ligação à secção Deteção de Rede do ficheiro de controlo do site com a
SMS_SCI_Componentclasse .Loop através da matriz de propriedades disponíveis, efetuar alterações conforme necessário.
Consolide as alterações ao ficheiro de controlo do site.
Efetue uma ligação à secção Deteção de Rede do ficheiro de controlo do site com a
SMS_SCI_Configurationclasse .Loop através da matriz de propriedades disponíveis, efetuar alterações conforme necessário.
Consolide as alterações ao ficheiro de controlo do site.
Exemplo
O exemplo seguinte define as definições de Deteção de Rede ao utilizar as SMS_SCI_Component classes e SMS_SCI_Configuration para ligar ao ficheiro de controlo do site e alterar as propriedades.
Observação
A Deteção de Rede é invulgar, uma vez que requer a definição das SMS_SCI_Component propriedades de classe e SMS_SCI_Configuration para ativar o componente.
Para obter informações sobre como chamar o código smple, veja Calling Configuration Manager Code Snippets (Chamar fragmentos de código Configuration Manager).
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;
}
}
O método de exemplo tem os seguintes parâmetros:
| Parâmetro | Tipo | Descrição |
|---|---|---|
- connection- swbemServices |
- Gerido: WqlConnectionManager- VBScript: SWbemServices |
Uma ligação válida ao Fornecedor de SMS. |
swbemContext |
- VBScript: SWbemContext |
Um objeto de contexto válido. Para obter mais informações, veja How to Add a Configuration Manager Context Qualifier by Using WMI (Como Adicionar um Qualificador de Contexto do Configuration Manager através da WMI). |
siteCode |
- Gerido: String- VBScript: String |
O código do site. |
serverName |
- Gerido: String- VBScript: String |
O nome do servidor. |
enableDisableDiscovery |
- Gerido: String- VBScript: String |
Um valor para ativar ou desativar o método de deteção. Desativado - falseAtivado - true |
Compilando o código
Este exemplo de C# requer:
Namespaces
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Programação robusta
Para obter mais informações sobre o processamento de erros, veja About Configuration Manager Errors (Acerca dos Erros de Configuration Manager).
Segurança do .NET Framework
Para obter mais informações sobre como proteger aplicações Configuration Manager, veja Configuration Manager administração baseada em funções.
Confira também
Acerca do Configuration Manager Ficheiro de Controlo de SitesComo Ler e Escrever no Ficheiro de Controlo de Sites Configuration Manager Utilizando Código GeridoComo Ler e Escrever no Ficheiro de Controlo de Site Configuration Manager utilizando a Classe WMI de Servidor WMI do SMS_SCI_Component sobre agendasComo Criar um Token de Agenda