7

I'm running a script in which I want to mark as checked all renderings of a specific template with the Vary By Data parameter. But running the script it is adding to the Additional Parameters the value as opposed to checking the checkbox for the respective parameter as shown bellow:

enter image description here

Anyone know what I'm missing? Here is my script

$items = Get-ChildItem -Recurse | Where-Object {$_.TemplateID -match "{79A0F7AB-17C8-422C-B927-82A1EC666ABC}"} | ForEach-Object {
$renderingInstance = Get-Rendering -Item $_ -Rendering $rendering
if($renderingInstance){
    Set-Rendering -Item $_ -Instance $renderingInstance -Parameter @{
        VaryByData = "$true"
    }
}}
1
  • Update one item manually (using rendering parametrs dialog), copy raw vales of __Final Renderings and __Renderings fields, then revert item (i suppose you've got source control), update the item with script and compare values in external tool. You will notice what is wrong there. Apr 28, 2017 at 7:54

1 Answer 1

6

It's actually easier than that (only showing partial code):

if ($renderingInstance) {
    $renderingInstance.Cachable = 1
    $renderingInstance.VaryByData = 1
    Set-Rendering -Item $_ -Instance $renderingInstance
}

This will update the checkboxes on the shared layout. You can omit the Cachable (sic) setting if your rendering instances are already set to be cached, or if don't want to activate caching for all of them.

1
  • I knew I was missing something siily. Thanks @maz
    – Diego
    Apr 28, 2017 at 17:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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