Environment: Windows 7 SP1, Server 2008 R2 SP1, Server 2012 R2, Powershell 3
I have developed an installer using PowerShell for our suite of web applications. Depending on the environment, I am running into an error when setting or clearing the physical path credentials. The error states that the configuration section is locked in a parent file. It is not clear to me what section is causing trouble or why I can't specify a location tag to write to an unlocked section.
I have looked through the machine.config, root web.config, and applicationHost.config files and it appears the file causing problems is applicationHost.config. I have scoured the online help and every thread I could find that referenced section locking and physical path credentials, but there is no reference to what feature or locking section corresponds to the virtual directory physical path credentials settings.
Overall, I find the IIS delegation architecture and terminology confusing, and the Powershell web configuration API interface somewhat awkward. I must be missing something, or asking the wrong question, because I am stuck on something that should be straightforward.
Here is the offending code:
# Set the physical path credentials of the web application (equivalent to IIS Manager web app Basic Settings screen, Connect As...)
$filter="/system.applicationHost/sites/site[@name='{0}' and @id='1']/application[@path='/{1}']/VirtualDirectory[@path='/']" -f $script:WebSiteName,$appName
Set-WebConfiguration $filter -Value @{userName="$physicalPathCredentialUserID";password="$physicalPathCredentialPassword"} -PSPath IIS:\ -location "$script:WebSiteName/$appName" -Force
I find that the PSPath, location and force options have no effect when a parent section is locked.
Any help is appreciated. I figure if it can't be answered here, it can't be answered!
Regards