My website is using the App Center Placeholder device on all of the pages. I would like to use Sitecore PowerShell Extensions (SPE) to deprecate the App Center Placeholder device and move all the associated presentation details for all the pages within sitecore/content/MyWebSite to the Mobile device instead.

Figure 1 shows the devices. Figure 2 shows an example of where I am currently at. And, Figure 3 is an example of where I want to be.

All the pages have different child controls and the child control properties would also need to be copied to the Mobile device from the App Center Placeholder device. (See Figure 4)

We are using Sitecore 8.1 Update 3 and SPE 4.6.

Figure 1

enter image description here

Figure 2

enter image description here

Figure 3

enter image description here

Figure 4

enter image description here

1 Answer 1


You could loop through the content items you need to update, and then use a string replace to change the App Center Placeholder device Id with the Mobile device Id.

Here is an example of how you might script it. Caveat - this is untested code, so test it before running it on your entire content tree! Also, with this code, it doesn't check if the item already has content

$mobileDeviceId = Get-LayoutDevice -Name "Mobile" | % { $_.Id.Guid.ToString("B") } | Select-Object -First 1
$appCenterDeviceId = Get-LayoutDevice -Name "App Center Placeholder" | % { $_.Id.Guid.ToString("B") } | Select-Object -First 1

$items = Get-ChildItem -Path master:\content\mysite -Recurse 
foreach($item in $items) {
    # Replace the appcenter device id with the mobile device id
    $renderingsText = $item.__Renderings
    $newRenderingsText = $renderingsText.Replace($appCenterDeviceId, $mobileDevice)

    # do the same for the Final Layout
    $finalLayoutText = $item.__Final
    $newFinalLayoutText = $finalLayoutText.Replace($appCenterDeviceId, $mobileDevice)

    $item["__Renderings"] = $newRenderingsText
    $item["__Final Renderings"] = $newFinalLayoutText
  • $item.Editing.EndEdit() is returning false and the $item does not seem to be updating.
    – ADH
    Commented Aug 16, 2017 at 7:19

Your Answer

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

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