【问题标题】:Use PowerShell to iterate through all WebConfiguration Properties for IIS使用 PowerShell 遍历 IIS 的所有 WebConfiguration 属性
【发布时间】:2016-06-27 20:58:09
【问题描述】:

我想尝试遍历应用程序在 IIS 中的所有可用配置选项,以便我可以通过 PowerShell 设置它们。我对 IIS 或 PowerShell 并不十分熟悉,所以我正在尽力而为。以下输出是我尝试遍历应用程序的所有配置时得到的结果。

PS C:\Users\User01> $siteName = "CustomApp"
PS C:\Users\User01> $authentications = Get-WebConfiguration -filter "system.webServer/*" -PSPath "IIS:\Sites\Default Web Site\$siteName"
PS C:\Users\User01> foreach ($auth in $authentications) { Write-Host $auth }
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
PS C:\Users\User01> $authentications = Get-WebConfiguration -filter "system.webServer/*" -PSPath "IIS:\Sites\Default Web Site\$siteName" -Recurse
PS C:\Users\User01> foreach ($auth in $authentications) { Write-Host $auth }
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection
Microsoft.IIs.PowerShell.Framework.ConfigurationSection

我应该怎么做才能获得实际的项目名称而不是显示的名称?

【问题讨论】:

    标签: asp.net windows powershell iis


    【解决方案1】:

    尝试使用 -recurse 函数来遍历所有这些。

    【讨论】:

    • 我添加了 -recurse 标志和相同的结果。
    【解决方案2】:

    试试这个而不是你的“写主机”

    {$auth|gm}
    

    【讨论】:

      猜你喜欢
      • 2015-11-29
      • 1970-01-01
      • 2015-07-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-09-09
      • 2010-10-06
      • 2017-05-20
      相关资源
      最近更新 更多