【发布时间】:2020-11-18 21:43:16
【问题描述】:
我只需要在网站下的一个文件上允许“anonymousAuthentication”,但是将这些行添加到 web.config 告诉我我不能覆盖父设置。我查看了 applicationHost.config 的文档,如果我手动将 overrideMode="Allow" 添加到 location 行,它应该可以工作(并且确实可以)但我找不到如何使用 powershell 执行此操作(我们正在尝试编写整个事情的脚本通过ansible和powershell)
applicationHost 中的网站配置如下所示:
<location path="mywebsite"> <-line should be <location path="mywebsite" overrideMode="Allow" >
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
我为单个文件尝试了 Set-WebConfigurationProperty,但它在 applicationHost 中创建了另一个部分来控制设置,这不是我们想要的,因为 web.config 保持锁定,所以未来的更改仍然必须在 applicationHost.config
有谁知道能不能做到?
编辑:更多信息:这是我们想要在 web.config 中工作的内容
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<defaultDocument>
<files>
<add value="mainf.htm" />
</files>
</defaultDocument>
</system.webServer>
<location path="probe.txt">
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
<windowsAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
</configuration>
【问题讨论】:
-
没有用于操作锁定设置的 cmdlet。以管理员身份运行您的脚本并使用直接 XML 文件操作来编辑
applicationHost.config。
标签: powershell iis