【发布时间】:2019-05-25 05:07:36
【问题描述】:
我需要修改默认位于 c:\windows\System32\inetsrv\config 的 applicationHost.config 文件。
查看 XML 文件,在配置中有许多位置条目。我只需要修改一个特定的。也许在修改它之前先检查它是否存在?
以下 XML 是我要修改的内容。嵌套在顶级配置下。如果发现为假,我只想更改一项,anonymousAuthentication enabled="true"。
<location path="Default Web Site/MyWebsite/SiteA">
<system.webServer>
<security>
<authentication>
<digestAuthentication enabled="false" />
<basicAuthentication enabled="false" />
<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true">
<providers>
<clear />
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
</authentication>
</security>
</system.webServer>
</location>
附注。我确实看到我可以使用 set-webconfigurationproperty。但是,当我这样做时,它告诉我配置部分不能在此路径中使用。当该部分锁定在父级别时会发生这种情况。我正在使用 PSPath,它应该可以解决这个问题,但它不起作用。
【问题讨论】:
-
关于您的旁注,您可能需要进入 IIS 服务器 (inetmgr.cpl) 的功能委托并设置身份验证 - 匿名读取/写入,然后再次尝试使用
set-webconfigurationproperty
标签: xml powershell