Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jondjones/68d44857f4ceff954ff5eb2a2f2e9ef5 to your computer and use it in GitHub Desktop.
Save jondjones/68d44857f4ceff954ff5eb2a2f2e9ef5 to your computer and use it in GitHub Desktop.
Powershell Script To Enable Proxy Within IIS (ARR) - 1
$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemrootsystem32inetsrvMicrosoft.Web.Administration.dll")
$manager = new-object Microsoft.Web.Administration.ServerManager
$sectionGroupConfig = $manager.GetApplicationHostConfiguration()
$sectionName = 'proxy';
$webserver = $sectionGroupConfig.RootSectionGroup.SectionGroups['system.webServer'];
if (!$webserver.Sections[$sectionName])
{
$proxySection = $webserver.Sections.Add($sectionName);
$proxySection.OverrideModeDefault = "Deny";
$proxySection.AllowDefinition="AppHostOnly";
$manager.CommitChanges();
Write-Host "Commited Section Group";
}
$manager = new-object Microsoft.Web.Administration.ServerManager
$config = $manager.GetApplicationHostConfiguration()
$section = $config.GetSection('system.webServer/' + $sectionName)
$enabled = $section.GetAttributeValue('enabled');
$section.SetAttributeValue('enabled', 'true');
$manager.CommitChanges();
Write-Host "Commited Section";
@markusstoll
Copy link

thank you, but I think you lost some backslashes.
Should'nt the first line rather be

$assembly = [System.Reflection.Assembly]::LoadFrom("$env:systemroot\system32\inetsrv\Microsoft.Web.Administration.dll")

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