Wcf 设置WebConfiguration属性失败

Wcf 设置WebConfiguration属性失败,wcf,iis,powershell,Wcf,Iis,Powershell,我正在尝试使用powershell在IIS中的站点上设置windowsauth,到目前为止,脚本的这一部分在所有环境中都有效,但现在失败了,我无法找出原因 Set-WebConfigurationproperty system.webServer/security/authentication/anonymousAuthentication -name enabled -value false -PSPath "IIS:\" -location $siteName Set-WebConfigur

我正在尝试使用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身份验证,网站运行正常

欢呼声

1)验证.NET framework 3.0(或更高版本)是否已安装

2) 以管理员身份执行以下命令:

%WINDIR%\Microsoft.Net\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe“-i


希望能有所帮助

因此,问题在于没有安装.Net 3.5

由于powershell在未安装3.5的情况下在.Net2 CLR下运行,因此它不知道web.config中的system.serviceModel是什么


安装3.5后,脚本运行正常

我没有安装.Net 3,但在4.0目录中找到了相同的.exe。该命令要求您指定要安装的软件包,因此我使用了-ia,这是所有软件包。不幸的是,这会产生相同的错误:(忘记告诉您安装3.5 SP1…!干得好!