Search code examples
powershelliispowershell-2.0powershell-3.0

How to use Set-ItemProperty to set EnabledProtocols for each Application associated with IIS WebSite?


The following powershell successfully updates the EnabledProtocols property for my WebSite "Test Services"

Set-ItemProperty 'IIS:\sites\Test Services' -name EnabledProtocols -Value 
"http,net.tcp,net.pipe"

Are there any Powershell gurus here who know the syntax for setting the EnabledProtocols property for each WebApplication associated with the WebSite "Test Services"?


Solution

  • You need to find applications under a site using a where $_.Schema.Name -eq "Application". Then for each application using the Set-ItemProperty, set enabledProtocols property value.

    Example

    You should run the following script as administrator:

    Import-Module WebAdministration -Force
    Get-ChildItem "IIS:\sites\test" |
        Where-Object {$_.Schema.Name -eq "Application"} | 
        ForEach-Object { 
            Set-ItemProperty $_.PSPath `
            -name enabledProtocols -Value "http,net.tcp,net.pipe"}
    

    Important Notes

    • The script should be run as administrator.
    • Pay attention to character case of the property name.
    • Also make sure WebAdministration module is imported.) Also pay attention to the enabledProtocols name, with camel case syntax.