如何使用 Set-ItemProperty 为与 IIS WebSite 关联的每个应用程序设置 EnabledProtocols?
How to use Set-ItemProperty to set EnabledProtocols for each Application associated with IIS WebSite?
以下 powershell 成功更新了我的网站 "Test Services"
的 EnabledProtocols 属性
Set-ItemProperty 'IIS:\sites\Test Services' -name EnabledProtocols -Value
"http,net.tcp,net.pipe"
这里是否有 Powershell 专家知道为与网站 "Test Services" 关联的每个 WebApplication 设置 EnabledProtocols 属性 的语法?
您需要使用 where $_.Schema.Name -eq "Application"
在站点下查找应用程序。然后为每个使用 Set-ItemProperty
的应用程序设置 enabledProtocols
属性 值。
例子
您应该 运行 作为管理员执行以下脚本:
Import-Module WebAdministration -Force
Get-ChildItem "IIS:\sites\test" |
Where-Object {$_.Schema.Name -eq "Application"} |
ForEach-Object {
Set-ItemProperty $_.PSPath `
-name enabledProtocols -Value "http,net.tcp,net.pipe"}
重要提示
- 脚本应该是 运行 作为管理员。
- 注意 属性 名称的字符大小写。
- 还要确保
WebAdministration
模块已导入。)
还要注意 enabledProtocols
名称,使用驼峰语法。
以下 powershell 成功更新了我的网站 "Test Services"
的 EnabledProtocols 属性Set-ItemProperty 'IIS:\sites\Test Services' -name EnabledProtocols -Value
"http,net.tcp,net.pipe"
这里是否有 Powershell 专家知道为与网站 "Test Services" 关联的每个 WebApplication 设置 EnabledProtocols 属性 的语法?
您需要使用 where $_.Schema.Name -eq "Application"
在站点下查找应用程序。然后为每个使用 Set-ItemProperty
的应用程序设置 enabledProtocols
属性 值。
例子
您应该 运行 作为管理员执行以下脚本:
Import-Module WebAdministration -Force
Get-ChildItem "IIS:\sites\test" |
Where-Object {$_.Schema.Name -eq "Application"} |
ForEach-Object {
Set-ItemProperty $_.PSPath `
-name enabledProtocols -Value "http,net.tcp,net.pipe"}
重要提示
- 脚本应该是 运行 作为管理员。
- 注意 属性 名称的字符大小写。
- 还要确保
WebAdministration
模块已导入。) 还要注意enabledProtocols
名称,使用驼峰语法。