Friday, April 10, 2015

Sitecore PowerShell Extensions Tip - Count Items

Today I needed a quick report to find out the number of "pages" on our site. I came up with a quick estimate using the Sitecore PowerShell Extensions module.

# List of template ids to exclude from the count.
$templateIds = @(
"{29FD19B5-6F81-4829-B725-9C4279DA13CE}",
"{C3C9ED41-B476-49A9-B50C-FF8901665EA0}",
"{5A905A62-4898-44CE-96BA-EB3432BAAD91}"
)
@(Get-Item -Path master:\content\home) + @(Get-ChildItem -Path master:\content\home -Recurse) |
Where-Object { $templateIds -notcontains $_.TemplateId } |
Select-Object -Property Name, TemplateId |
Measure-Object
view raw Count Items.ps1 hosted with ❤ by GitHub
I hope this encourages you to spend a little more time in SPE.

// michael