Scenario: Assume a new rendering is created and we need to assign this rendering to multiple items in the Sitecore content tree. while this can be done manually it will be time consuming and boring task for content authors. Again Powershell come to the rescue.
Get Item where rendring needs to be assigned.
$item=Get-Item -Path “master:” -ID “{3512740C-8965-4E40-A082-0F528A638111}”
Get rendering which needs to be assigned on the above item
$RenderingName = Get-Item -Path “master:” -ID {209B30A5-495C-4AF0-A670-8287E78107DE}
write-host “adding rendering…”
Add-Rendering -Item $Item -PlaceHolder “content123” -DataSource “” -Instance (New-Rendering -Item $RenderingName)
write-host “add rendering completed…”
Note: Here you can provide the Placeholder and Datasource too based on the requirement.
The same Process can be automated with multiple items and multiple renderings where you are reading the item IDs from a csv file and assigning the renderings in a foreach loop.