Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
AdamNaj / Find-EmptyFolders.ps1
Created May 13, 2021
Show report of empty folders in Sitecore Media library
View Find-EmptyFolders.ps1
$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") {
View Remove-OldItemVersion.ps1
function Remove-OldItemVersion {
[CmdletBinding()]
param(
[Parameter(Position = 0,Mandatory = $true,ValueFromPipeline = $true)]
[ValidateNotNullOrEmpty()]
[Sitecore.Data.Items.Item]$Item,
[Parameter(Position = 1,Mandatory = $true)]
[ValidateNotNullOrEmpty()]
[int]$MaxVersions
)
@AdamNaj
AdamNaj / Find-AbandonedEntities.ps1
Last active Jan 18, 2021
How to check if Z-Wave node is Secure or Plus version based on QZW Config file.
View Find-AbandonedEntities.ps1
# 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 / Get-SiteStyles.ps1
Created Jan 5, 2021
Get Styles inventory from a given SXA website
View Get-SiteStyles.ps1
$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 / about.md
Last active Nov 18, 2020
Z Wave Graph for Home Assistant
View about.md
@AdamNaj
AdamNaj / Get-VariantRoots.ps1
Created Jun 16, 2019
Ret Rendering Variant Roots for all sites
View Get-VariantRoots.ps1
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 / Get-TaggedItems.ps1
Created Nov 10, 2018
Querying Habitat Legal Site for Tags
View Get-TaggedItems.ps1
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
@AdamNaj
AdamNaj / Import.ps1
Created Nov 7, 2018
Wordpress XML (to SXA) import script (messy output)
View Import.ps1
$xmlPath = "$AppPath\sugcon.xml"
$pageTemplate = "Project/Community/Page"
$siteHome = "master:\content\Community\SUGCON\Home"
$sitepath = "master:\content\Community\SUGCON"
[string[]]$content = get-content $xmlPath
[xml]$xml = $content
$pages = $xml.rss.channel.item | %{ [PSCustomObject]@{
@AdamNaj
AdamNaj / Set-ItemFieldToExternalLink.ps1
Created Oct 26, 2015
Set item field to external url
View Set-ItemFieldToExternalLink.ps1
@AdamNaj
AdamNaj / Clone Site.ps1
Created Jun 13, 2018
Modify SXA "Clone Site" script to be able to clone sites with Security set up on them.
View Clone Site.ps1
# Open the following item:
# /sitecore/system/Modules/PowerShell/Script Library/SXA/SXA - Multisite/Content Editor/Context Menu/Clone Site
# inside the try{ } clause wrap its content with:
New-UsingBlock(New-Object -TypeName "Sitecore.SecurityModel.SecurityDisabler"){
# all code that was inside the try clause before - goes here
}