PowerShell IIS Set-WebConfigurationProperty - Locked section ApplicationHost.config

I am writing a PowerShell 3.0 installer for our web applications and web services, and when I try to set the credentials of the physical path, I try to work.

My code is as follows:

# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
# >>>>>> Path credentials
# >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>

# Set the physical path credentials of the web application (on Basic Settings screen) to 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"} 

When I execute, I get an error in PowerShell: "This configuration section cannot be used along this path. This occurs when the section is locked at the parent level." I tried PSPath tags and locations that work when authentication sections are locked, but they don't seem to have any effect. I thought that perhaps the -Force option would work, but although no error was selected, the credentials of the physical path did not seem to be accepted.

-Force , PowerShell , , , . , "", :/configuration/system.applicationHost/sites/application/virtualDirectory

, . PowerShell WebAdministration . , , , , IIS. Set-WebConfiguration , , Set-WebConfigurationProperty. , , ?

. , , -, "- ".

2014 PowerShell 3.0? PSPath ?

, :

$filter="/system.applicationHost/sites/site[@name='{0}' and    @id='1']/application[@path='/{1}']/VirtualDirectory[@path='/']" -f $script:WebSiteName,$appName
Set-WebConfiguration $filter machine/webroot/appHost -metadata overrideMode -value Allow

, .

virtualDirectoryDefaults.userName virtualDirectoryDefaults.password, , , , IISReset , applicationHost.config. , , .

, . -, -.

+4
2

, , IIS. , .

: IIS Powershell

+1

. XPath. , //authentication/*, node. , XPath, . , , sectionGroup location, Filter.

, Windows , Windows auth . - :

Set-WebConfiguration -Metadata OverrideMode -Value Allow -Filter //windowsAuthentication
Set-WebConfigurationProperty -PSPath IIS:\Sites\$WebsiteName\$AppName -Filter //windowsAuthentication -Name Enabled -Value $true

, applicationHost.config, :

<location path="" overrideMode="Allow">
        <system.webServer>
            <security>
                <authentication>
                    <windowsAuthentication>
                    </windowsAuthentication>
                </authentication>
            </security>
        </system.webServer>
</location>

, , IIS, .

, Web.config -:

<authentication>
    <windowsAuthentication enabled="true" />
</authentication>

, .

0

All Articles