Created
March 28, 2020 15:04
-
-
Save jondjones/68d44857f4ceff954ff5eb2a2f2e9ef5 to your computer and use it in GitHub Desktop.
Powershell Script To Enable Proxy Within IIS (ARR) - 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$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"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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")