Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<log4net>
<!-- Add a StringMatchFilter into the LogFileAppender -->
<appender name="LogFileAppender" type="log4net.Appender.RollingFileAppender, Sitecore.Logging">
<filter type="log4net.Filter.StringMatchFilter">
<stringToMatch value="Results endpoint exception" />
<acceptOnMatch value="false" />
</filter>
@michaellwest
michaellwest / ReserializeItems.ps1
Created February 17, 2023 15:44
Reserialize Unicorm items using Sitecore PowerShell Extensions. Useful when fields are missing and need to be regenerated.
$lines = @"
/sitecore/content/home
"@
$paths = $lines.Split([Environment]::NewLine, [StringSplitOptions]::RemoveEmptyEntries)
foreach($path in $paths) {
Get-Item -Path ($path.Replace("/sitecore", "master:")) | Export-UnicornItem
}
@michaellwest
michaellwest / ContentMigratorAllSites.ps1
Created February 15, 2023 19:33
Sitecore PowerShell Extensions Content Migrator for all sites using SXA Get-AllSxaSite.
Clear-Host
Import-Module -Name SPE -Force
$scriptDirectory = & {
if ($psISE) {
Split-Path -Path $psISE.CurrentFile.FullPath
} else {
$PSScriptRoot
}
@michaellwest
michaellwest / IAR.101.config
Created February 7, 2023 01:16
Sample configuration for Sitecore 10.1 using IAR. Adds an additional location that is later included by default in 10.2.
<?xml version="1.0" encoding="utf-8" ?>
<!--
Purpose: Adds in an additional location to load IAR files from
This config can be removed if the project is upgraded to 10.2+ since the path is set ootb
-->
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/">
<sitecore>
<databases>
<database id="master" role:require="Standalone or ContentManagement">
<dataProviders>
@michaellwest
michaellwest / ExceptionMessage.txt
Last active January 31, 2023 20:38
Issues related to a LetsEncrypt certificate unable to validate against the Certificate Revocation List (CRL).
Exception: System.Security.Authentication.AuthenticationException
Message: The remote certificate is invalid according to the validation procedure.
Source: System
at System.Net.Security.SslState.StartSendAuthResetSignal(ProtocolToken message, AsyncProtocolRequest asyncRequest, Exception exception)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.CheckCompletionBeforeNextReceive(ProtocolToken message, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.ProcessReceivedBlob(Byte[] buffer, Int32 count, AsyncProtocolRequest asyncRequest)
at System.Net.Security.SslState.StartReceiveBlob(Byte[] buffer, AsyncProtocolRequest asyncRequest)
@michaellwest
michaellwest / CheckCertRevocation.ps1
Last active January 31, 2023 17:46
Check certificate revocation using PowerShell.
# Potential workaround for errors:
# https://stackoverflow.com/questions/2675133/c-sharp-ignore-certificate-errors
# https://stackoverflow.com/a/66882479/1277533
$webRequest = [Net.WebRequest]::Create("https://www.company.com")
try { $webRequest.GetResponse() } catch {}
$cert = $webRequest.ServicePoint.Certificate
#$bytes = $cert.Export([Security.Cryptography.X509Certificates.X509ContentType]::Cert)
#set-content -value $bytes -encoding byte -path "$pwd\company.cer"
#certutil.exe -verify -urlfetch "$pwd\company.cer"
@michaellwest
michaellwest / inspect.ps1
Last active January 22, 2023 04:36
List Docker Container Name and IPAddress as a table using PowerShell.
docker ps -q | ForEach-Object { "Name,IPAddress" } { $data = docker inspect $_ --format '{{json .Name}},{{range .NetworkSettings.Networks}}{{json .IPAddress}}{{end}}'; $data.replace('/','') } | ConvertFrom-Csv
<#
Name IPAddress
---- ---------
spe-traefik-1 172.31.127.71
spe-cm-1 172.31.126.246
spe-id-1 172.31.116.201
spe-mssql-1 172.31.120.96
spe-solr-1 172.31.121.74
@michaellwest
michaellwest / SplunkQuery.txt
Last active January 18, 2023 19:52
Split query string data into table format with Splunk.
index=iis sourcetype=ms:iis:auto NOT cs_uri_stem="/sitecore/service/keepalive.aspx" NOT cs_User_Agent="*PRTG+Network+Monitor*" cs_uri_stem="/sxa/search/results*" | rex field=cs_uri_query max_match=0 "[\&]?(?<qkey>[^=]+)=(?<qvalue>[^&]+)?"
| eval fields = mvzip(qkey,qvalue)
| mvexpand fields
| eval pairs=split(fields,",")
| eval key=mvindex(pairs,0), value=mvindex(pairs,1)
| fields cs_host cs_uri_query a g q
| eval a=urldecode(a)
| eval g=urldecode(g)
| eval q=urldecode(q)
| stats values(*) as * by cs_uri_query
@michaellwest
michaellwest / CurlCMError.ps1
Created January 16, 2023 21:01
Curl the home page when the CM reports unhealthy. For use with Sitecore and Docker.
$containers = docker ps -a --format "table {{.Names}}"
$container = $containers | ConvertFrom-Csv | Where-Object { $_.NAMES -match "-cm" } | Select-Object -First 1 -ExpandProperty NAMES
docker exec $container curl http://cm
@michaellwest
michaellwest / DatabaseMissing.yml
Last active January 16, 2023 19:26
Sample content for michaellwest.blogspot.com post.
---
ID: "9c7e7d60-bfa0-4fec-b55c-462b3efdd545"
Parent: "839b77db-6040-4f00-8771-8e96fd37aba2"
Template: "854ba861-63ea-4a0c-8c7b-541e9a7ec4c1"
Path: /sitecore/system/Settings/Foundation/Scms/Search/Search Query Rules Context/Tags/Default
DB: master