简体   繁体   English

通过 Powershell 将代理元素添加到 system.webServer 部分的 applicationHost.config

[英]Add proxy element to applicationHost.config in system.webServer section via Powershell

I am trying to add <proxy enabled="true" /> element under system.webServer section.我正在尝试在system.webServer部分下添加<proxy enabled="true" />元素。

Add-WebConfigurationProperty -Filter '/system.webServer/proxy' -Name . -Value @{ enabled="true" }

Above command does nothing.上面的命令什么都不做。

Add-WebConfigurationProperty -Filter '/system.webServer' -Name 'proxy' -Value @{ enabled="true" }

Above command throws error: Property proxy is not found on system.webServer上面的命令抛出错误: Property proxy is not found on system.webServer

Add-WebConfiguration -Filter '/system.webServer/proxy' -Value @{ enabled="true" }

Also does nothing.也什么都不做。

Set-WebConfigurationProperty -Filter '/system.webServer/proxy' -Name 'enabled' -Value 'true'

Shows warning: Target configuration object '/system.webServer/proxy is not found at path 'MACHINE/WEBROOT/APPHOST'.显示警告: Target configuration object '/system.webServer/proxy is not found at path 'MACHINE/WEBROOT/APPHOST'.

I find these commands very counterintuitive.我发现这些命令非常违反直觉。 What is the right way to add new element?添加新元素的正确方法是什么?

EDIT:编辑:

I was testing these commands on Windows 2019 Core with default IIS 10.0我在 Windows 2019 Core 上测试这些命令,默认为 IIS 10.0

I have Windows Server 2012 R2 with IIS 8.5我有 Windows Server 2012 R2 和 IIS 8.5

I can setup proxy on Win2012 with command appcmd set config -section:system.webServer/proxy /enabled:"true" /commit:apphost , but the same command doesn't work on Win2019.我可以使用命令appcmd set config -section:system.webServer/proxy /enabled:"true" /commit:apphost在 Win2012 上设置代理,但相同的命令在 Win2019 上不起作用。 It shows error Unknown config section "system.webServer/proxy".它显示错误Unknown config section "system.webServer/proxy". So, this setting may be not valid for IIS 10.0因此,此设置可能对 IIS 10.0 无效

First you need to make sure ARR has install like Lex Li said.首先,您需要确保 ARR 已像 Lex Li 所说的那样安装。

Then try this powershell command, it can work well in my server 2019.然后尝试这个 powershell 命令,它可以在我的服务器 2019 中正常运行。

Set-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST'  -filter "system.webServer/proxy" -name "enabled" -value "True"

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 添加一个 <location /> 通过PowerShell将applicationHost.config转换为元素 - Add a <location /> element to applicationHost.config through PowerShell PowerShell IIS Set-WebConfigurationProperty - 锁定的ApplicationHost.config部分 - PowerShell IIS Set-WebConfigurationProperty - Locked ApplicationHost.config section 如何使用appcmd在applicationhost.config中为部分编辑overrideModeDefault - How to edit overrideModeDefault in applicationhost.config for section using appcmd Powershell搜索ApplicationHost.config文件并替换值 - Powershell Search ApplicationHost.config file and replace value 加 <clear /> 和 <remove name=something /> 使用Powershell Webadministration模块标记到applicationHost.config或web.config中的集合 - add <clear /> and <remove name=something /> tag to collections in applicationHost.config or web.config using Powershell webadministration module 在applicationHost.config上执行Powershell替换会导致格式不正确的xml错误 - Powershell replace on applicationHost.config causing not well-formed xml errors 如何使用Powershell和IISAdministration模块在applicationHost.config中不存在位置/时创建位置 - How to create location/ when it doesn't exist in applicationHost.config with Powershell and IISAdministration module 使用 IISAdministraton PowerShell 模块获取 IIS applicationHost.config 日志文件设置 - Geting IIS applicationHost.config LogFile settings using IISAdministraton PowerShell module 由于applicationHost.config无效,.Net构建失败 - .Net build is failing due to invalid applicationHost.config 删除ApplicationHost配置文件中的元素 - Removing Element in ApplicationHost Config file
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM