Tuesday, 20 October 2015

How To Create Bulk Items in Sitecore Using Powershell Script?

Many times you need to create bulk items in Sitecore for some reason. May be you want to check the performance of your newly implemented feature. Let's say you want to check how your code (e.g search code) is performing when there are tons of items.

So once again you can take the advantage of Sitecore Powershell script here. Below is the small yet powerful Sitecore Powershell script (.ps) which will empower you to create desired number of items based on given template.
#This script will create sitecore items based on given count and template
$InputCount = Show-Input "How many items do you want to create?"
$InputTemplate = Show-Input "Using which template you want to create item?"
$getCurrentItem = Get-Item .
$NewItemPath = $getCurrentItem.FullPath
$CurrentChildCount = $getCurrentItem.Children.Count+1
for ($index = $CurrentChildCount; $index -lt $CurrentChildCount+$InputCount; $index++) 
   new-item -Path $NewItemPath -Name $index -type $InputTemplate
You can create the script named Create Bulk Items  under /sitecore/system/Modules/PowerShell/Script Library/Package Generator/Content Editor/Context Menu/Packaging

When you run above script, it will ask you:

1) How many number of items do you want to create?

2) Using which template you want to create items?

Below screen summarizes the entire step by step process to create bulk items in Sitecore.

This script is powered by Sitecore Powershell Extensions, so please make sure that you have Powershell extensions installed in your Sitecore instance. If you want to download Sitecore Powershell Extensions, click here for the same.

Empower you Sitecore Journey by using Sitecore Powershell Extensions!


  1. Thanks for using SPE! We really appreciate it. For those interested, here are some additional dialogs included with SPE https://sitecorepowershell.gitbooks.io/sitecore-powershell-extensions/content/interactive-dialogs.html

    1. Thank you Michael West!

      We couldn't be using SPE without you, it's you who invented it.

  2. Hi Nilesh,

    That's a great use case for Sitecore PowerShell Extensions. I noticed you could improved the script slightly by using the Read-Variable command - if you're interested - I've uploaded a modified version of your script here: https://gist.github.com/AdamNaj/fa65b877ea6547eaad6b

    Great job!

    1. Thank you Adam!

      Will definitely follow you by using Read-Variable. Thanks for sharing it!

  3. Good work Nilesh. And also thanks to Michael and Adam to make this wonderful utility. It helped me lot.Very productive tool to be used during development.

  4. Your way is somehow unique