I am trying to build a Powershell script to automate connection string changes to our deployed web applications.
I am trying to use the WebAdministration
command Set-WebApplicationProperty
but am recieving an error about an Unrecognized element: 'providerOption'
PS IIS:\Sites\Default Web Site\VirtualPath> Set-WebConfigurationProperty "//connectionStrings/*[@name='DefaultConnection']" -Name ConnectionString -Value "<NEW CONNECTION STRING>" -PSPath (Get-Location).Path
Set-WebConfigurationProperty : Filename: \\?\C:\Windows\Microsoft.NET\Framework64\v4.0.30319\CONFIG\web.config
Line number: 53
Error: Unrecognized element 'providerOption'
At line:1 char:1
+ Set-WebConfigurationProperty "//connectionStrings/*[@name='DefaultConnection']" ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Set-WebConfigurationProperty], COMException
+ FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Microsoft.IIs.PowerShell.Provider.SetConfigurationPropertyCommand
I found some information about the same error on StackOverflow, but it appears to be related to the original release of .NET 4.0 : https://stackoverflow.com/questions/21308965/unrecognized-element-provideroption
Some additional environment information:
OS: Windows Server 2008 R2
IIS: 7.5
Powershell: v4.0
.NET Framework Version: 4.5.2
Also worth noting is that this command works just fine on Window 8.1, IIS 8.5, Powershell 4.0, .NET 4.5.2
EDIT: On a hunch I compared the Web.config
specified in the error between a machine which works and a machine which does not. They are identical.