Insights

Find Sitecore Items Without A Language Version

Using Powershell

Use Case

Recently, I ran across a problem where I was missing items in a web database. They were not getting published to the master database because there were no language versions for those items. This causes a lot of confusion because what you see in Sitecore Experience Editor ends up not matching what you see on the front-end site.

Most Powershell commands that retrieve items require a - Language parameter to retrieve specific versions. If you leave the language param off, it will use “en” as the default choice. If you pass an empty string for this param, it will return all versions of items that have language versions. But still my scenario was uncovered i.e the items without a language version.

I created the below powershell script to resolve the issue. It gives you a list with a full path of all items with no language version.

Powershell Script

You can change $folder value depending upon the node on which you want to run this script. Also combine the Where-Object clause with other parameters like Name or Template if you are looking for something specific

 
$folder = "/sitecore"
$items = Get-ChildItem -Path $folder -recurse | Where-Object { $_.Versions.GetVersions($true).Count -eq 0 } 

ForEach ($item in $items) 
{
    $path = $item.Paths.FullPath 
    Write-Host $path
   
}
 

If you want to reproduce it, just create a new item, then go to the “Versions” tab and delete the current version.

Happy Coding!

Hey, Developers!

We're on the look out for talented developers to join our team.

Think you have what it takes?