Automated Sitecore deployment with the usage of Jenkins and Nexus Repository Manager

I wrote an article describing the process of automated deployment built with the usage of Jenkins and Nexus Repository Manager. You can find this article on Konabos’s website: https://konabos.com/blog/sitecore-upgrade-deployment-aws-virtual-servers-jenkins-nexus-repository-manager

How to find all of the Sitecore Items that use aliases?

Recently I had to find all the items being linked by aliases. Because we had hundreds of aliases and no one wanted to go one by one to check where are they linking to I decided to prepare a PowerShell script to generate a report. Here is the code of it:

$itemList = @()
$allPaths = @(
    "master:\system\Aliases"
    )
    
ForEach($path in $allPaths)
{
    $itemList += Get-ChildItem $path -Recurse | Where-Object {
        $_.TemplateID -eq "{54BCFFB7-8F46-4948-AE74-DA5B6B5AFA86}"
    }
}

$reportProps = @{
    Title = "Aliases Report"
    InfoTitle = "This is a report showing items being linked by aliases"
    InfoDescription = "Total entries found: $($itemList.length)"
    PageSize = 25
}

$report = New-Object System.Collections.Generic.List[PSObject]

ForEach ($item in $itemList)
{    
    $linkedItem = $item.PSFields."Linked item"
    $found = $linkedItem.Value -match '.*id="(.*?)".*'
    $foundItemPath = ""
    $foundID = ""
    if ($found)
    {
        $foundID = $matches[1]
        
        if ($foundItem = Get-Item -Path "master:" -ID $foundID -ErrorAction SilentlyContinue)
        {
            $foundItemPath = $foundItem.FullPath
        }
        else
        {
            $foundItemPath = "Broken Link"
        }
        
    }
    
    $newObject = New-Object PSObject @{__Icon = $item.__Icon; DisplayName = $item.DisplayName; FullPath = $item.FullPath; ID = $item.ID; URL = $linkedItem.Url; LinkedItemPath = $foundItemPath; LinkedItemID = $foundID}
    $report.Add($newObject)
}

$report | Show-ListView @reportProps -Property `
    @{ Label = "Alias Path"; Expression = { $_.FullPath} },
    @{ Label = "Alias Id"; Expression = { $_.ID } },
    @{ Label = "LinkedItem ID"; Expression = { $_.LinkedItemID } },
    @{ Label = "Linked Url"; Expression = { $_.URL } },
    @{ Label = "LinkedItem Path"; Expression = { $_.LinkedItemPath } }
Close-Window

Data migration strategy as a crucial part of Sitecore upgrade

Recently I wrote a blog post describing the challenges of the Sitecore upgrades and now on the Konabos website we released a continuation written by me. I share some knowledge about data migration strategies – you can find it here: Rethinking Sitecore Upgrades: The Art and Science of Content Migration

How to find all unused Sitecore Templates?

Recently one of the customers had a need to identify all of the templates that are not in use. We could go through all of the templates manually and verify all the links but with PowerShell we can do that much faster. Here is a script that will generate a report (that you can later download as Excel).

In this report, you will see all the templates and references – then with the help of Excel filtering you can filter out the rows without any references to get the list of unused templates.

$itemList = @()
$allPaths = @(    
    "master:\templates\Feature",
    "master:\templates\Foundation",
    "master:\templates\Project"
    )

ForEach($path in $allPaths)
{
    $itemList += Get-ChildItem $path -Recurse | Where-Object {
        $_.TemplateID -ne "{0437FEE2-44C9-46A6-ABE9-28858D9FEE8C}" -and $_.TemplateID -ne "{85ADBF5B-E836-4932-A333-FE0F9FA1ED1E}" -and $_.FullPath -notLike "*/System/*" -and $_.FullPath -notLike "*/Experience Accelerator/*" -and $_.FullPath -notLike '*/JSS Experience Accelerator/*' -and $_.FullPath -notLike '*$name*' -and $_.TemplateID -ne "{E269FBB5-3750-427A-9149-7AA950B49301}" -and $_.TemplateID -ne "{455A3E98-A627-4B40-8035-E683A0331AC7}" -and $_.TemplateID -ne "{A46706F7-EAF8-4575-9860-A85B6F17C5EB}" -and $_.TemplateID -ne "{239F9CF4-E5A0-44E0-B342-0F32CD4C6D8B}" -and $_.Name -ne "__Standard Values"
    }
}

$reportProps = @{
    Title = "Templates references"
    InfoTitle = "This report shows all references of the templates"
    InfoDescription = "Total entries found: $($itemList.length)"
    PageSize = 25
}

$report = New-Object System.Collections.Generic.List[PSObject]

ForEach ($item in $itemList)
{
    Write-Host "Referrers for "+ $item.FullPath
    $referrers = Get-ItemReferrer -Item $item
    $referrersPaths = New-Object System.Collections.Generic.List[String]
    $referrers| ForEach-Object -Process { $referrersPaths.Add($_.FullPath) }
    
    $newObject = New-Object PSObject @{__Icon = $item.__Icon; DisplayName = $item.DisplayName; FullPath = $item.FullPath; ID = $item.ID; Status = $status; Referrers = ($referrersPaths -join "|")}
    $report.Add($newObject)
}


$report | Show-ListView @reportProps -Property `
    @{ Label = "Item Name"; Expression = { $_.DisplayName } },
    @{ Label = "Path"; Expression = { $_.FullPath} },
    @{ Label = "Id"; Expression = { $_.ID } }
    @{ Label = "Referrers"; Expression = { $_.Referrers } }
Close-Window

From the list of all paths we exclude things like:

  • folders
  • standard values
  • SXA templates
  • system templates
  • and few more