Skip to content

Instantly share code, notes, and snippets.

@AdamNaj
Last active January 5, 2017 23:50
Show Gist options
  • Save AdamNaj/fa65b877ea6547eaad6b to your computer and use it in GitHub Desktop.
Save AdamNaj/fa65b877ea6547eaad6b to your computer and use it in GitHub Desktop.
#This script will create sitecore items based on given count and template
$InputCount=10
$InputTemplate = Get-Item "master:\templates\Sample\Sample Item"
$result = Read-Variable `
-Parameters @{Name="InputCount"; Title="How many items do you want to create?"},
@{Name="InputTemplate"; Title="Using which template you want to create item?"; root="/sitecore/templates/"} `
-Title "Bulk item create tool" `
-Description "Please provide the number of items and the template that you want to be used"
if($result -eq "ok"){
$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.Paths.Path
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment