
我正在管理一台伺服器核心計算機,並嘗試在 PowerShell 中完成所有操作,這很有趣。我需要預設文檔的清單。從其他網站,我找到如何使用 xxx-WebConfiguration 和 xxx-WebConfigurationProperty 設定和刪除它們。我試過了:
Get-WebConfigurationProperty -Filter /system.webServer/defaultDocument -PSPath "IIS:\sites\Default Web Site" -Name files
但它給了:
Collection : {Microsoft.IIs.PowerShell.Framework.ConfigurationElement, Microsoft.IIs.PowerShell.Framework.Configuration
Element, Microsoft.IIs.PowerShell.Framework.ConfigurationElement, Microsoft.IIs.PowerShell.Framework.Confi
gurationElement...}
ItemXPath : /system.webServer/defaultDocument
Attributes : {}
ChildElements : {}
ElementTagName : files
Methods :
Schema : Microsoft.IIs.PowerShell.Framework.ConfigurationElementSchema
這並沒有真正的幫助。
答案1
實際的文檔名稱在層次結構中更深。以下是取得預設文件清單的方法:
Get-WebConfigurationProperty -Filter /system.webServer/defaultDocument/files/add -PSPath "IIS:\sites\Default Web Site" -Name value | Select value