Skip to content

Instantly share code, notes, and snippets.

@AlexKasaku
AlexKasaku / FindItems.ps1
Created April 16, 2024 14:41
Find Sitecore items by ancestor template
# Searches for Sitecore items in Master database that descend from a given template, sit
# underneath a particular ancestor item, and are the latest version.
class TemplatesSearchResultItem : SearchResultItem
{
# For items contained within an SXA index try using the name "inheritance_sm".
[Sitecore.ContentSearch.IndexField("_templates")]
[System.Collections.Generic.List[ID]]$TemplateIds
[Sitecore.ContentSearch.IndexField("_latestversion")]
@AlexKasaku
AlexKasaku / ohmyposh.json
Created December 21, 2023 10:15
Oh My Posh configuration
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"alignment": "left",
"segments": [
{
"background": "#0077c2",
"foreground": "#ffffff",
"leading_diamond": "",
@AlexKasaku
AlexKasaku / FixBrokenRenderings.ps1
Created November 5, 2020 19:50
Sitecore - Fix broken renderings
#
# Recurses through the content and finds all Renderings used by pages. Used to find any broken renderings.
# Assumes datasources can only be IDs, so setups that use queries can be flagged as incorrect (e.g. in SXA).
#
$rootItem = Get-Item -Path "master:/sitecore/content/website/Home"
$defaultLayout = (Get-LayoutDevice "Default")
# Set to true to only report on issues, rather than address them. If this is false, renderings deemed bad are removed!
$reportOnly = $True
@AlexKasaku
AlexKasaku / SitecoreAppInsightsQueries
Created May 1, 2020 16:07
Sitecore Application Insights queries
All non-INFO traces on the Content Management server:
traces
| where customDimensions.Role == "CM"
| where severityLevel > 1
| where timestamp between(datetime("2020-05-01 14:35:00") .. datetime("2020-05-01 14:45:00"))
| order by timestamp desc
@AlexKasaku
AlexKasaku / gist:19a94e25079a5fe3985b116c71e57f58
Created November 11, 2019 15:14 — forked from kamsar/gist:6407742
This class provides a method to 'upgrade' the hash algorithm used by the SqlMembershipProvider without resetting all existing passwords. Users can effectively then be authenticated using either legacy or modern hashes, and any time a hash gets touched it will be upgraded automatically.
using System;
using System.Collections.Specialized;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Web.Security;
@AlexKasaku
AlexKasaku / gist:52fa4e063733feaca2fab567beacfd30
Created August 22, 2019 21:25
FFMpeg - Convert audio to AC3
ffmpeg.exe -i "Video.mkv" -map 0 -vcodec copy -scodec copy -acodec ac3 -b:a 448k "AC3.mkv"
@AlexKasaku
AlexKasaku / Remove Site Language.ps1
Last active January 1, 2019 19:09
Remove a language from an SXA site. Based on the "Add Site Language" set of scripts that comes with SXA.
# Functions Site Language/Remove Site Language
Import-Function Validate-PowerShell
Test-PowerShell
Try
{
$ctx = Get-Item .
@AlexKasaku
AlexKasaku / CopyPathToClipboard.ps1
Created June 6, 2017 20:48
Copy path to clipboard
function cwd { $pwd.Path.Trim() | Set-Clipboard }
@AlexKasaku
AlexKasaku / DeleteContentDeliveryFiles.ps1
Created November 30, 2016 16:36
Delete Content Delivery files
#
# Takes a list of configuration files that should be disabled on a Content Delivery server and renames them with a
# .octopus_disabled suffix so they are not loaded.
#
# Prepared for Sitecore 8.1 Update 3
$baseFolder = "YOUR WEBSITE FOLDER"
$files = (
"App_Config\Include\001.Sitecore.Speak.Important.config",
@AlexKasaku
AlexKasaku / ChangeTemplateMaintainingLayout.ps1
Created November 10, 2016 17:18
Change template without breaking layout
$item = Get-Item -Path master: -ID "{C7FF7164-CECC-44A5-9A16-784619578316}"
$sharedLayout = $item.__Renderings
$finalLayout = $item."__Final Renderings"
if ([Sitecore.Xml.Patch.XmlPatchUtils]::IsXmlPatch($finalLayout))
{
$finalLayoutFull = [Sitecore.Data.Fields.XmlDeltas]::ApplyDelta($sharedLayout, $finalLayout)
}