Skip to content

Instantly share code, notes, and snippets.

@dazinator
Last active June 25, 2020 16:11
Show Gist options
  • Save dazinator/46ddf29f406bf66bc2b0 to your computer and use it in GitHub Desktop.
Save dazinator/46ddf29f406bf66bc2b0 to your computer and use it in GitHub Desktop.
Powershell to unlock IIS config section system.webServer/handlers
$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemroot\system32\inetsrv\Microsoft.Web.Administration.dll")
$manager = new-object Microsoft.Web.Administration.ServerManager
# load appHost config
$config = $manager.GetApplicationHostConfiguration()
Write-Host "Unlocking system.webServer/handlers"
$section = $config.GetSection('system.webServer/handlers')
$section.OverrideMode = 'Allow'
$manager.CommitChanges()
Write-Host "Unlocked system.webServer/handlers"
@mansing2
Copy link

This didn't work for me, I am trying to unlock section for an application created under a default web site.
The manual steps are as below

  1. Select an application from Default Web Site.
  2. From right pane select Configuration Editor under Management.
  3. From first drop down at top select system.webServer/handlers and from the next drop down select Applicationhost.Config<>
  4. From the most right pane under Section select 'Unlock Section'

I dont get any error after the above powershell is executed but system.webServer/Handlers still shows locked for that particular application available under default web site.

Any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment