首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用PowerShell循环访问IIS的所有WebConfiguration属性

使用PowerShell循环访问IIS的所有WebConfiguration属性
EN

Stack Overflow用户
提问于 2016-06-28 04:58:10
回答 2查看 637关注 0票数 0

我想尝试遍历应用程序在IIS中拥有的所有可用配置选项,这样我就可以通过PowerShell设置它们。我对IIS或PowerShell不是很熟悉,所以我会尽我最大的努力。以下输出是我尝试迭代应用程序的所有配置时得到的输出。

代码语言:javascript
复制
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

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

EN

回答 2

Stack Overflow用户

发布于 2016-06-29 01:38:29

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

票数 0
EN

Stack Overflow用户

发布于 2020-04-09 19:05:58

试试这个而不是你的“Write-Host”

代码语言:javascript
复制
{$auth|gm}
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38063123

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档