如何使用 PowerShell 获取 IIS 中的默认文档列表?

SGa*_*att 1 iis powershell windows-server-core

我正在管理服务器核心机器并尝试在 PowerShell 中完成所有操作,这很有趣。我需要一个默认文件的列表。从其他网站,我发现了如何使用 xxx-WebConfiguration 和 xxx-WebConfigurationProperty 设置和删除它们。我试过了:

Get-WebConfigurationProperty -Filter /system.webServer/defaultDocument -PSPath "IIS:\sites\Default Web Site" -Name files
Run Code Online (Sandbox Code Playgroud)

但它给出了:

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
Run Code Online (Sandbox Code Playgroud)

这并没有真正的帮助。

Sco*_*MVP 5

实际的文档名称在层次结构中更深。以下是获取默认文档列表的方法:

Get-WebConfigurationProperty -Filter /system.webServer/defaultDocument/files/add -PSPath "IIS:\sites\Default Web Site" -Name value | Select value
Run Code Online (Sandbox Code Playgroud)