Skip to content

Instantly share code, notes, and snippets.

@RobsonAutomator
Last active December 14, 2016 13:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RobsonAutomator/a04d57f335cbcf6deffed4997d2ebade to your computer and use it in GitHub Desktop.
Save RobsonAutomator/a04d57f335cbcf6deffed4997d2ebade to your computer and use it in GitHub Desktop.
Add handlers to web.config
$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