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
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