ConfiguredObject.GetAllSections Method1

检索已配置对象下的所有配置节。

语法

ConfiguredObject.GetAllSections(Sections);  
ConfiguredObject.GetAllSections Sections  

参数设置

名称 描述
Sections 一个 ConfigurationSection 变量,已配置对象的配置节将复制到其中。

返回值

此方法不返回值。

注解

GetAllSections 方法对于发现已配置对象的完整可用部分集非常有用。 有关配置属性的常规设置和获取,请参阅 ConfiguredObject.GetSection 方法。

注意

GetAllSections 方法签名包含一个 [OUT] 参数,用于接收该方法返回的部分。

示例

以下示例检索默认网站的 Site 对象,并使用 GetAllSections 方法检索和枚举该网站的配置节对象。

每个部分仅返回一个实例。 返回的值是正在使用的 ConfiguredObject 级别的有效配置。 所有返回对象的路径将与 ConfiguredObject 的路径匹配。

注意

仅返回指定的 ConfiguredObject 级别的对象。

' Connect to the WMI WebAministration namespace.  
Set oWebAdmin = _  
    GetObject("winmgmts:root\WebAdministration")  
  
' Get the default Web site.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
  
' Retrieve all configuration sections for the default Web  
' site and place them into an array variable.  
oSite.GetAllSections arySect  
  
' Display the number of configuration sections.  
WScript.Echo "There are " & UBound(arySect) + 1 & _  
    " configuration sections for [" & oSite.Name & "]."  
WScript.Echo vbCrLf  
  
' Iterate through the sections.  
For aryIdx = 0 To UBound(arySect)  
  
    ' Number the section for display.  
    WScript.Echo aryIdx + 1 & "."  
  
    ' Show the section name.  
    WScript.Echo "[" & arySect(aryIdx).Path_.Class & "]"  
  
    ' Show the section path and location.  
    WScript.Echo "Path: " & arySect(aryIdx).Path  
    WScript.Echo "Location: " & arySect(aryIdx).Location  
  
    ' Show the SectionInformation properties.  
    WScript.Echo "SectionInformation.OverrideMode: " & _  
        arySect(aryIdx).SectionInformation.OverrideMode  
    WScript.Echo _  
        "SectionInformation.EffectiveOverrideMode: " & _  
        arySect(aryIdx).SectionInformation.EffectiveOverrideMode  
    WScript.Echo "SectionInformation.IsLocked: " & _  
        arySect(aryIdx).SectionInformation.IsLocked  
    WScript.Echo "SectionInformation.LockItem: " & _  
        arySect(aryIdx).SectionInformation.LockItem  
  
    WScript.Echo vbCrLf  
Next  
  

要求

类型 描述
客户端 - IIS 7.0(在 Windows Vista 上)
- IIS 7.5(在 Windows 7 上)
- IIS 8.0(在 Windows 8 上)
- IIS 10.0(在 Windows 10 上)
服务器 - IIS 7.0(在 Windows Server 2008 上)
- IIS 7.5(在 Windows Server 2008 R2 上)
- IIS 8.0(在 Windows Server 2012 上)
- IIS 8.5(在 Windows Server 2012 R2 上)
- IIS 10.0(在 Windows Server 2016 上)
产品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 文件 WebAdministration.mof

另请参阅

ConfiguredObject 类
ConfiguredObject.GetSection 方法