使用PowerShell迭代IIS的所有WebConfiguration属性

时间:2016-06-27 20:58:10

标签: asp.net windows powershell iis

我想尝试遍历应用程序在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

如何获取实际的项目名称而不是显示的内容?

2 个答案:

答案 0 :(得分:0)

尝试使用-recurse函数迭代所有这些函数。

答案 1 :(得分:-2)

尝试使用此方法,而不要使用“写入主机”

{$auth|gm}