共用方式為


ConfiguredObject.GetAllSections 方法1

擷取已設定物件下的所有組態區段。

語法

ConfiguredObject.GetAllSections(Sections);  
ConfiguredObject.GetAllSections Sections  

參數

名稱 描述
Sections ConfigurationSection變數,其中會複製所設定物件的組態區段。

傳回值

這個方法不會傳回值。

備註

方法 GetAllSections 適用于探索已設定物件的完整可用區段集。 如需一般設定和取得組態屬性,請參閱 ConfigureObject.GetSection 方法。

注意

方法 GetAllSections 簽章包含參數 [OUT] ,可接收方法傳回的區段。

範例

下列範例會擷取預設網站的 Site 物件,並使用 GetAllSections 方法來擷取和列舉網站的組態區段物件。

每個區段只會傳回一個實例。 傳回的值是所使用 ConfigurationObject 層級的有效組態。 所有傳回物件的路徑都會符合 的 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  
  

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

ConfiguredObject 類別
ConfiguredObject.GetSection 方法