设置 WebConfigurationProperty 失败
我正在尝试使用 powershell 在 IIS 中的站点上设置 windowsauth,这部分脚本到目前为止已在所有环境中运行,但现在失败了,我无法弄清楚原因。
Set-WebConfigurationproperty system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath "IIS:\" -location $siteName
Set-WebConfigurationproperty system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath "IIS:\" -location $siteName
有人知道为什么这个脚本会失败吗?
我收到“无法读取配置部分‘system.serviceModel’,因为它缺少部分声明”
我可以手动启用 Windows 身份验证,并且站点可以正常启动。
干杯
I am trying to use powershell to set windowsauth on a site in IIS, this part of the script has worked in all environments so far and has now failed and I cannot figure out why.
Set-WebConfigurationproperty system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath "IIS:\" -location $siteName
Set-WebConfigurationproperty system.webServer/security/authentication/windowsAuthentication -name enabled -value true -PSPath "IIS:\" -location $siteName
Anyone got any ideas as to why this script would fail?
I get a "The configuration section 'system.serviceModel' cannot be read because it is missing a section declaration"
I can manually enable windows auth and the site spins up just fine.
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
所以事实证明问题出在没有安装 .Net 3.5。
由于 powershell 在 .Net2 CLR 下运行而未安装 3.5,因此它不知道 web.config 中的 system.serviceModel 是什么。
安装 3.5 后,脚本运行良好
So it turns out the issue was not having .Net 3.5 installed.
As powershell runs under .Net2 CLR without having 3.5 installed it didn't know what system.serviceModel was in the web.config.
Once 3.5 was installed the script ran fine
1) 验证是否安装了.NET Framework 3.0(或更高版本)。
2)以管理员身份执行以下命令:
“%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe” -i
希望可以帮助
1) Verify the .NET framework 3.0 (or higher) is installed.
2) Execute the following command as administrator:
"%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe" -i
Hope can help