Last active
December 14, 2016 13:26
-
-
Save RobsonAutomator/a04d57f335cbcf6deffed4997d2ebade to your computer and use it in GitHub Desktop.
Add handlers to web.config
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
$webpath = 'E:\www\Sitecore8\Website\Web.config' | |
#var addElement = handlersCollection.CreateNewElement("add"); | |
#addElement.Properties.Item("name").Value = "PHP-FastCGI"; | |
[xml]$XmlDocument = Get-Content -Path $webpath | |
$handler = $XmlDocument.configuration.'system.webServer'.handlers.ChildNodes | Where-Object {$_.Name -eq 'CaptchaImage'} | |
if( $handler -eq $null ) | |
{ | |
$lastElement = $XmlDocument.configuration.'system.webServer'.handlers.LastChild.Clone() | |
$lastElement.name = 'CaptchaImage' | |
$lastElement.path = 'CaptchaImage.axd' | |
$lastElement.type = "Sitecore.Form.Core.Pipeline.RequestProcessor.CaptchaResolver, Sitecore.Forms.Core" | |
$lastElement.verb="*" | |
$XmlDocument.configuration.'system.webServer'.handlers.AppendChild($lastElement) | |
} | |
$handler = $XmlDocument.configuration.'system.webServer'.handlers.ChildNodes | Where-Object {$_.Name -eq 'CaptchaAudio'} | |
if( $handler -eq $null ) | |
{ | |
$lastElement = $XmlDocument.configuration.'system.webServer'.handlers.LastChild.Clone() | |
$lastElement.name = 'CaptchaAudio' | |
$lastElement.path = 'CaptchaAudio.axd' | |
$lastElement.type = "Sitecore.Form.Core.Pipeline.RequestProcessor.CaptchaResolver, Sitecore.Forms.Core" | |
$lastElement.verb="*" | |
$XmlDocument.configuration.'system.webServer'.handlers.AppendChild($lastElement) | |
} | |
$XmlDocument.Save($webpath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment