By default, Sitecore 9 ships with the customErrors mode set to RemoteOnly. I’m not complaining. But if you’re using SIF to configure a QA server, you may want to change that. In a push to have infrastructure as code, the module below actually does this for you. Here’s the modlue:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
Set-StrictMode -Version 2.0 Function Invoke-SetCustomErrorsModeTask { [CmdletBinding(SupportsShouldProcess = $true)] param( [Parameter(Mandatory = $true)] [string]$SiteFolder, [ValidateSet('On', 'Off', 'RemoteOnly', IgnoreCase = $false)] [Parameter(Mandatory = $true)] [string]$ErrorMode ) Write-TaskInfo "Locating web.config in folder $SiteFolder" -Tag 'UpdateMode' #Get the path of the web.config $WebConfigPath = Join-Path $SiteFolder "web.config" $WebConfigXML = New-Object XML $WebConfigXML.Load($WebConfigPath) $CustomErrorsNode = $WebConfigXML.SelectSingleNode("/configuration/system.web/customErrors") $CustomErrorsNode.SetAttribute("mode", $ErrorMode) $WebConfigXML.Save($WebConfigPath) } Register-SitecoreInstallExtension -Command Invoke-SetCustomErrorsModeTask -As SetCustomErrorsMode -Type Task |
Nothing really fancy here. …