|
| 1 | +----item---- |
| 2 | +version: 1 |
| 3 | +id: {50456B81-0FB3-4705-BC61-E6FDD2CF98A3} |
| 4 | +database: master |
| 5 | +path: /sitecore/system/Modules/PowerShell/Script Library/Examples/Content Maintenance/Mass Change Item Templates |
| 6 | +parent: {F25BF203-F58F-4F3C-B017-3ACD2F063479} |
| 7 | +name: Mass Change Item Templates |
| 8 | +master: {00000000-0000-0000-0000-000000000000} |
| 9 | +template: {DD22F1B3-BD87-4DB2-9E7D-F7A496888D43} |
| 10 | +templatekey: PowerShell Script |
| 11 | + |
| 12 | +----version---- |
| 13 | +language: en |
| 14 | +version: 1 |
| 15 | +revision: 1b5da6d3-8bcd-4f41-ba0f-ce0b04c88320 |
| 16 | + |
| 17 | +----field---- |
| 18 | +field: {B1A94FF0-6897-47C0-9C51-AA6ACB80B1F0} |
| 19 | +name: Script |
| 20 | +key: script |
| 21 | +content-length: 1505 |
| 22 | + |
| 23 | +<# |
| 24 | +Based on Blog by @Techphoria414 - Nick Wesselman |
| 25 | +http://www.techphoria414.com/Blog/2012/March/Change-Item-Templates-With-Sitecore-PowerShell |
| 26 | +#> |
| 27 | + |
| 28 | +$sourceTemplate = get-item 'master:\templates\Sample\Sample Item' |
| 29 | +$targetTemplate = get-item 'master:\templates\Sample\Sample Item' |
| 30 | +$branch = get-item . |
| 31 | +$result = Read-Variable -Parameters ` |
| 32 | + @{ Name = "branch"; Title="Branch to work on"; Root="/sitecore/"; Tooltip="Items you want to work on."}, ` |
| 33 | + @{ Name = "sourceTemplate"; Title="Current template"; Root="/sitecore/templates/"; Tooltip="Template you want to replace."}, ` |
| 34 | + @{ Name = "targetTemplate"; Title="New template"; Root="/sitecore/templates/"; Tooltip="Template you want to use."} ` |
| 35 | + -Description "This report will replace template on all items in the tree with another template of your choice" ` |
| 36 | + -Title "Branch Template Replace" -Width 500 -Height 400 ` |
| 37 | + -OkButtonName "Replace" -CancelButtonName "Cancel" |
| 38 | + |
| 39 | +if($result -ne "ok") |
| 40 | +{ |
| 41 | + Exit |
| 42 | +} |
| 43 | + |
| 44 | +$path = $branch.ProviderPath; |
| 45 | +cd $branch.ProviderPath; |
| 46 | +$targetTemplateItem = New-Object -TypeName "Sitecore.Data.Items.TemplateItem" -ArgumentList $targetTemplate |
| 47 | +Write-Host "For branch '$($branch.ProviderPath)' changing templates from '$($sourceTemplate.Name)' to '$($targetTemplate.Name)'" |
| 48 | +Get-ChildItem $path -recurse | Where-Object{$_.TemplateID -eq $sourceTemplate.ID} | ForEach-Object { $_.ChangeTemplate($targetTemplateItem); Write-Host "Changing $($_.ProviderPath)" }; |
| 49 | + |
| 50 | +Show-Result -Text -Width 800 -Height 700 |
| 51 | +Close-Window |
| 52 | +----field---- |
| 53 | +field: {25BED78C-4957-4165-998A-CA1B52F67497} |
| 54 | +name: __Created |
| 55 | +key: __created |
| 56 | +content-length: 15 |
| 57 | + |
| 58 | +20130902T111843 |
| 59 | +----field---- |
| 60 | +field: {8CDC337E-A112-42FB-BBB4-4143751E123F} |
| 61 | +name: __Revision |
| 62 | +key: __revision |
| 63 | +content-length: 36 |
| 64 | + |
| 65 | +1b5da6d3-8bcd-4f41-ba0f-ce0b04c88320 |
| 66 | +----field---- |
| 67 | +field: {D9CF14B1-FA16-4BA6-9288-E8A174D4D522} |
| 68 | +name: __Updated |
| 69 | +key: __updated |
| 70 | +content-length: 34 |
| 71 | + |
| 72 | +20130902T111843:635137175234032422 |
| 73 | +----field---- |
| 74 | +field: {BADD9CF9-53E0-4D0C-BCC0-2D784C282F6A} |
| 75 | +name: __Updated by |
| 76 | +key: __updated by |
| 77 | +content-length: 14 |
| 78 | + |
| 79 | +sitecore\admin |
0 commit comments