更新时间:2023-02-25 20:48:39
您不需要单独的 -PSPath
和 -Location
参数。你可以像这样组合它们:
You don't need separate -PSPath
and -Location
parameters. You can combine them like this:
-PSPath "IIS:\Sites\$SiteName\$AppName"
所以实际命令如下所示:
So the actual command will look like this:
Set-WebConfigurationProperty -Filter "/system.webServer/security/authentication/windowsAuthentication" -Name Enabled -Value True -PSPath "IIS:\Sites\$SiteName\$AppName"
请注意,您可能会遇到此错误:
Note that you may run into this error:
Set-WebConfigurationProperty:此配置部分不能在此路径中使用。当该部分被锁定在父级别时会发生这种情况。锁定是默认情况下(overrideModeDefault =Deny),或由locationMode =Deny或旧版allowOverride =false的位置标记显式设置。
Tomfanning在ServerFault上提供了此处的解决方案。我在这里重复了他的步骤:
Tomfanning over at ServerFault provided the solution here. I have repeated his steps here: