Skip to content

Instantly share code, notes, and snippets.

@dnstommy
Last active November 26, 2016 22:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dnstommy/5b29e18c87a39338765118925e895754 to your computer and use it in GitHub Desktop.
Save dnstommy/5b29e18c87a39338765118925e895754 to your computer and use it in GitHub Desktop.
## Can use Path or ID to get the item
$newTemplate = Get-Item "{622A0FF0-2628-423B-9B79-3A7249804635}";
$searchItems = Find-Item `
-Index sitecore_master_index `
-Criteria @{Filter = "Equals"; Field = "_name"; Value = "Menus"},
@{Filter = "StartsWith"; Field = "_fullpath"; Value = "/sitecore/content/" }
@{Filter = "Equals"; Field = "templateid"; Value = "1e96593acae043acbaebf3497072b118" }
if($searchItems)
{
foreach($searchItem in $searchItems)
{
$id = $searchItem.ItemId
Write-Host $searchItem.Path
$item = Get-Item $id
$item.ChangeTemplate($newTemplate)
}
}
else
{
Write-Host "No Items to change"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment