Skip to content

Instantly share code, notes, and snippets.

View AdamNaj's full-sized avatar

Adam Najmanowicz AdamNaj

View GitHub Profile
@AdamNaj
AdamNaj / Find-MostExecutedSolrQuery.ps1
Last active June 2, 2024 18:34
Most executed Solr queries from latest Sitecore logs
# Gets the latest 30 log files, filters only solr query lines from them, groups them by query content and orders by most executed,
# Letting you find things that are most effective to cache.
Set-HostProperty -HostWidth 2000
$logFileFilter = "azure.log.*"
$logfileCountToAnalyse = 30
$minQueryOccurence = 20
Get-ChildItem $SitecoreLogFolder -Recurse -Filter $logFileFilter `
@AdamNaj
AdamNaj / Test-TenantTemplates.ps1
Last active April 9, 2024 15:11
Assert Tenant Templates from source tenant are also in the second tenant and contain the same base templates.
$aName = "Metro"
$aName = "Crafted"
$fromName = "/$aName/"
$toName = "/$($aName)VC/"
$tenantFrom = gci "master:\templates\Project$fromName" | ? { $_.TemplateName -eq "Template" }
$tenantFromIDs = $tenantFrom.ID;
$tenantTo = gci "master:\templates\Project$toName" | ? { $_.TemplateName -eq "Template" }
$tenantToIDs = $tenantTo.ID;
@AdamNaj
AdamNaj / zzz_dev.config.sample
Last active May 10, 2023 09:48
Optimize your Sitecore instance for Development. Drop files in: <website>\App_Config\Include\zzzz and rename to enable as needed.
<!--
IMPORTANT: This configuration file is not intended for any production Sitecore installation.
Purpose: This include file contains some experimental optimizations that can speed up start-up.
Please, review each of the patched elements below and consider if some of the optimizations should be commented out due to the specifics of your solution.
Enabling this file without taking into account the specifics of your solution can have unexpected consequences.
To enable this include file, rename it to have a ".config" extension.
@AdamNaj
AdamNaj / Get-ActiveSitesInSiteProvider.ps1
Created May 10, 2023 09:03
Get all sites that are active in your Sitecore instance:
[Sitecore.Sites.SiteManager]::GetSites() |
% {
$props = @{};
$_.Properties.GetEnumerator() | ForEach-Object {
$props[$_.Key] = $_.Value
}
[PSCustomObject]$props
} | Show-ListView -Title "Active site properties" -Icon "office/32x32/window_earth.png"
@AdamNaj
AdamNaj / Find-EmptyFolders.ps1
Created May 13, 2021 07:29
Show report of empty folders in Sitecore Media library
$source = Get-Item "master:\media library"
$readonly = $false;
$result =
Read-Variable `
-Parameters @{ Name = "root"; Title="Root folder"; Root="/sitecore/media library"; editor="item"} `
-Title "Find Empty Folders" `
-Description "Select the location you want to inspect." `
-OkButtonName "Clone"
if ($result -eq "ok") {
@AdamNaj
AdamNaj / Get-SiteStyles.ps1
Created January 5, 2021 12:28
Get Styles inventory from a given SXA website
$siteroot = "master:\content\Sitecore\MVP"
gci "$($siteroot)\Presentation\Styles" -Recurse |
? { $_.TemplateName -eq "Style" } |
select-object @{Name="EE Category / Horizon Controller Name"; Expression={$_.Parent.DisplayName}},
@{Name="Horizon Controller Type"; Expression={$_.Parent.Fields["Type"]}},
@{Name="Style Name"; Expression={$_.DisplayName}},
@{Name="CSS Class"; Expression={$_.Value}},
@{Name="Allowed on Components"; Expression={($_.PSFields."Allowed Renderings".Items |
% { Get-Item master:\ -ID $_ } |
@AdamNaj
AdamNaj / Get-VariantRoots.ps1
Created June 16, 2019 19:05
Ret Rendering Variant Roots for all sites
Set-HostProperty -HostWidth 5000
$roots = @()+[Sitecore.Sites.SiteManager]::GetSites() | ? { $_.Properties['IsSxaSite'] } | % { $_.Properties['rootPath'] };
foreach ($root in $roots) {
$site = New-Object -TypeName PSCustomObject
Add-Member -InputObject $site -Name 'path' -Value $root -MemberType NoteProperty
$variants = New-Object -TypeName PSCustomObject
Add-Member -InputObject $site -Name 'variants' -Value $variants -MemberType NoteProperty
$variantFolders = gci "master:$($root)/Presentation/Rendering Variants" | select Name, @{Name = "Path"; Expression={$_.paths.Path}}
foreach($variantFolder in $variantFolders){
@AdamNaj
AdamNaj / Find-AbandonedEntities.ps1
Last active January 18, 2021 20:54
How to check if Z-Wave node is Secure or Plus version based on QZW Config file.
# Combine the functionality of Find-ChattyZwaveDevices and Get-ZwaveNodeSecureOrPlus
# Executing this script can take a few minutes debending on the speed of the network and the size of your OZW log.
# Path to your Home Assistant shared folder - mapped drive on your windows machine
$haPath = "I:"
# Get the content of the Open Z-Wave cache file
Write-Progress -Activity "Reading Configuration"
[xml]$ozwCfg = Get-Content "$haPath\zwcfg_*.xml"
# Get valid zwave IDs
@AdamNaj
AdamNaj / about.md
Last active July 13, 2022 19:50
Z Wave Graph for Home Assistant
@AdamNaj
AdamNaj / Get-TaggedItems.ps1
Created November 10, 2018 14:19
Querying Habitat Legal Site for Tags
gci -path 'master:\content\Habitat sites\Habitat Legal\Home\News' |
%{ [PSCustomObject]@{ Name=&{$_.Title};
Author=&{@( $_.PSFields.Author.Items |
%{ gi master: -id $_ } |
%{ "$($_._Name) ($($_.JobTitle))" }) -join ", "};
Tags=&{@( $_.PSFields.SxaTags.Items |
%{ gi master: -id $_ } |
%{ $_.Name }) -join ", "}
} } | ft -prop @{name="Name"; width=50; Expression={$_.Name}},
@{name="Author"; width=60; Expression={$_.Author}}, Tags