Bemærk
Adgang til denne side kræver godkendelse. Du kan prøve at logge på eller ændre mapper.
Adgang til denne side kræver godkendelse. Du kan prøve at ændre mapper.
Retrieves the contents of a configuration section for a configured object.
Syntax
ConfiguredObject.GetSection(SectionName, Section);
ConfiguredObject.GetSection SectionName, Section
Parameters
| Name | Description |
|---|---|
SectionName |
A string variable that contains the name of the configuration section to be retrieved (for example, "BasicAuthenticationSection"). |
Section |
A ConfigurationSection variable into which the contents of the configuration section are placed. |
Return Value
This method does not return a value.
Remarks
You can use the GetSection method to retrieve the contents of a desired configuration section and set its configurable properties.
Note
The GetSection method signature contains an [IN] parameter for the section name and an [OUT] parameter for the section object that the method returns.
Example
The following example gets the HTTP errors section for the default Web site and displays both its array and non-array properties.
' 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
Requirements
| Type | Description |
|---|---|
| Client | - IIS 7.0 on Windows Vista - IIS 7.5 on Windows 7 - IIS 8.0 on Windows 8 - IIS 10.0 on Windows 10 |
| Server | - IIS 7.0 on Windows Server 2008 - IIS 7.5 on Windows Server 2008 R2 - IIS 8.0 on Windows Server 2012 - IIS 8.5 on Windows Server 2012 R2 - IIS 10.0 on Windows Server 2016 |
| Product | - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0 |
| MOF file | WebAdministration.mof |
See Also
ConfigurationSection Class
ConfiguredObject Class
HttpErrorElement Class
HttpErrorsSection Class