有人知道如何通过<location /> cmdlet向applicationHost.config文件添加一个新的根级WebAdministration元素吗?有Get-WebConfigurationLocation (以及cmdlet的“删除”和“重命名”版本),但没有“添加”。我使用Add-WebConfiguration尝试过许多不同的方法,但是我没有取得任何成功。
我尝试过的一些事情:
Add-WebConfiguration -Filter '/' -AtIndex 0 -Value @{ location = @{ site='bobDev' } }
Add-WebConfiguration -Filter '/' -AtIndex 0 -Value '<location site="bobDev" />'
Add-WebConfiguration -Filter '/' -AtIndex 0 -Value @{value="bobDev.html" }我知道我正在尝试的Value可能不正确,但我至少希望看到一些东西被添加到我的applicationHost.config中。
发布于 2018-04-19 16:11:03
不确定你是否解决了你的问题。已经好几年了。我偶然发现了你的职位。我只是想分享一下我是如何解决我的问题的,这样其他人就可以根据需要使用它了。
这个链接非常有用:生成脚本
下面的行将添加一个新的位置,并向您的位置添加参数。
Add-WebConfigurationProperty -pspath 'MACHINE/WEBROOT/APPHOST' -location 'mysite/devtest' -filter "system.webServer/security/ipSecurity" -name "." -value @{ipAddress='10.200.0.0';subnetMask='255.255.0.0';allowed='True'}
Set-WebConfigurationProperty -PSPath 'MACHINE/WEBROOT/APPHOST' -location 'mysite/devtest' -filter "system.webServer/security/ipsecurity" -Name "." -value @{allowUnlisted="false";enableProxyMode="true";denyAction="NotFound"}输出:
<location path="mysite/devtest">
<system.webServer>
<security>
<ipSecurity allowUnlisted="false" enableProxyMode="true" denyAction="NotFound">
<add ipAddress="10.200.0.0" subnetMask="255.255.0.0" allowed="true" />
</ipSecurity>
</security>
</system.webServer>
</location>https://stackoverflow.com/questions/40343112
复制相似问题