0

I'd like to set the Page Design field in certain pages of a certain template to a value in sitecore using powershell script. I tried the following but it didn't work. I also tried the name of the page design itself instead of the ID but also didn't work.

cd 'master:/sitecore/content/'
Get-ChildItem -Recurse . | Where-Object { $_.TemplateName -match "{TemplateName}"} | ForEach-Object {   
    $_.Editing.BeginEdit()
    $_.Fields["Page Design"].Value = "{000000-0000-0000-0000-00000000000}";
    $_.Editing.EndEdit()
    ""
}
  • what sort of error comes up? – Mie ElMansy Jan 21 at 10:49
  • no errors...the value just isn't set – Basant A. Jan 21 at 10:57
1

I found out how to do it. I was able to do it using the following script

$items = Get-ChildItem -Path '/sitecore/content/' -Recurse | 
    Where-Object { $_.TemplateName -eq "TemplateName"}

foreach($item in $items){
    $item.Editing.BeginEdit()
    $item["Page Design"] = "{000000-0000-0000-0000-000000000}";
    $item.Editing.EndEdit()
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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