locked
Powershell WebAdministration module update? RRS feed

  • Question

  • Getting the following error when using Powershell 2.0 (and specifically the WebAdministration module):

    Error: The configuration section 'standardEndpoints' cannot be read because it is missing a section declaration

    This looks to be an issue with the Common Language Runtime (CLR) version Powershell 2.0 supports.

    Reproduce this by running the following in powershell:

    Import-Module Webadministration

    Set-WebConfigurationProperty -Force -filter "/system.WebServer/security/authentication/windowsAuthentication" -name "Enabled" -pspath IIS:\ -location (("IIS:\Sites\InternalServices\ReapService" -replace "IIS:\\Sites\\", "") -replace "\\", "/") -value $true

    To find out what version of CLR powershell supports you can run the following command: $psversiontable

    Modules (such as the imported WebAdministration one used above) support certain CLR versions.  To find this out you can look at their *.psd1 file (C:\Windows\System32\WindowsPowerShell\v1.0\Modules\WebAdministration\WebAdministration.psd1).  In this case it is:

    @{

    GUID='{MUNGED}'

    Author='Microsoft Corporation'

    CompanyName='Microsoft'

    Copyright='© Microsoft Corporation. All rights reserved.'

    ModuleVersion='1.0.0.0'

    PowerShellVersion='2.0'

    CLRVersion='2.0.50727'

    TypesToProcess='iisprovider.types.ps1xml'

    FormatsToProcess='iisprovider.format.ps1xml'

    NestedModules='Microsoft.IIS.PowerShell.Provider.dll','WebAdministrationAliases.ps1'

    RequiredAssemblies='Microsoft.IIS.PowerShell.Framework.dll'

    AliasesToExport='Begin-WebCommitDelay','End-WebCommitDelay'

    }

    Therefore, web admin functionality in the script (such as Set-WebConfigurationProperty) only supports .NET 2.0 (that includes .NET framework 3.5 and below). 

    Furthermore, when you run that command, it looks at your app’s web.config file (since some settings can be overridden there) to determine how to do it’s setting.  If it can’t load a section (i.e. standardEndpoints) it will fail.  The web.config being used is configured for standardEndpoints and that section is part of .NET 4.0 (so you can’t set it via Set-WebConfigurationProperty).  Thus exists our problem space. 

    Any suggestions would be greatly appreciated, as we're trying to leverage Powershell and WebAdministration modules vs. having to call appcmd.exe (or some other workaround) to set the property.

    • Moved by Mike Feng Wednesday, June 26, 2013 2:55 PM
    Tuesday, June 25, 2013 5:08 PM

Answers