I am currently trying to find and delete broken links in the Sitecore master database. I am using a version of this script. The problem I am having is that the number of items in the content tree is huge (thousands of items) so the site becomes unresponsive whenever I run the script to search the whole database.

The script I am using is currently using Get-ChildItem as seen below, in order to get the items to search for broken links:

$items = Get-ChildItem -Path $root.ProviderPath -Recurse | HasBrokenLink -IncludeAllVersions (!$searchVersion)

I am wondering if there is a faster method I can use to search the content tree, such as fast query. I have looked everywhere, but haven't found any examples of a broken link report script that uses anything other than Get-ChildItem and -Recurse.

Is there a better method to find broken links in the master database?

1 Answer 1


You can have a look at the following answer for several ways to query items in PowerShell.

I would suggest you try the call to Axes to get items fast.

$mediaItemContainer = Get-Item "master:/media library" 
$items = $mediaItemContainer.Axes.GetDescendants() | 
    Where-Object { [int]$_.Fields["Size"].Value -gt 100000 } | Initialize-Item 

Looks like I already changed this behavior for a future release (maybe 4.8).

$items = @($root) + @(($root.Axes.GetDescendants() | Initialize-Item)) | 
    HasBrokenLink -IncludeAllVersions (!$searchVersion)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.