Condividi tramite


Metodo ConfiguredObject.GetSection

Recupera il contenuto di una sezione di configurazione per un oggetto configurato.

Sintassi

ConfiguredObject.GetSection(SectionName, Section);  
ConfiguredObject.GetSection SectionName, Section  

Parametri

Nome Descrizione
SectionName Variabile string che contiene il nome della sezione di configurazione da recuperare, ad esempio "BasicAuthenticationSection".
Section Variabile ConfigurationSection in cui vengono inseriti i contenuti della sezione di configurazione.

Valore restituito

Questo metodo non restituisce valori.

Commenti

È possibile usare il GetSection metodo per recuperare il contenuto di una sezione di configurazione desiderata e impostarne le proprietà configurabili.

Nota

La firma del GetSection metodo contiene un [IN] parametro per il nome della sezione e un [OUT] parametro per l'oggetto sezione restituito dal metodo.

Esempio

Nell'esempio seguente viene visualizzata la sezione Errori HTTP per il sito Web predefinito e vengono visualizzate sia le relative proprietà di matrice che non di matrice.

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
' Get the default Web site.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
  
' Get the HTTP errors section by using the GetSection method.  
oSite.GetSection "HttpErrorsSection", oSection  
  
' Display a heading.  
WScript.Echo "=============================="  
WScript.Echo "Http Errors Section Properties"  
WScript.Echo "=============================="  
  
' Display the HttpErrorsSection non-array properties.  
For Each vProp In oSection.Properties_  
    If (vProp.Name <> "HttpErrors") And _  
        (vProp.Name <> "SectionInformation") Then  
        WScript.Echo vProp.Name & ": " & vProp.Value  
    End If  
Next  
WScript.Echo   
  
' Display the HttpErrorsSection SectionInformation properties.  
WScript.Echo "HttpErrorsSection.SectionInformation"  
WScript.Echo "------------------------------------"  
For Each vProp In oSection.SectionInformation.Properties_  
    WScript.Echo vProp.Name & ": " & vProp.Value  
Next  
WScript.Echo  
  
' Display the contents of the HttpErrors array property.  
WScript.Echo "HttpErrorsSection.HttpErrors"  
WScript.Echo "----------------------------"  
For Each oHttpErrorElement In oSection.HttpErrors  
    For Each vProp In oHttpErrorElement.Properties_  
        WScript.Echo vProp.Name & ": " & vProp.Value  
    Next  
    WScript.Echo  
Next  
  

Requisiti

Tipo Descrizione
Client - IIS 7.0 in Windows Vista
- IIS 7.5 in Windows 7
- IIS 8.0 in Windows 8
- IIS 10.0 in Windows 10
Server - IIS 7.0 in Windows Server 2008
- IIS 7.5 in Windows Server 2008 R2
- IIS 8.0 in Windows Server 2012
- IIS 8.5 in Windows Server 2012 R2
- IIS 10.0 in Windows Server 2016
Prodotto - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
File MOF WebAdministration.mof

Vedere anche

Classe ConfigurationSection
Classe ConfiguredObject
Classe HttpErrorElement
Classe HttpErrorsSection