Skip to content

Instantly share code, notes, and snippets.

@AlexKasaku
Last active November 2, 2016 18:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexKasaku/968fbfc883042840dbbdc21662f37001 to your computer and use it in GitHub Desktop.
Save AlexKasaku/968fbfc883042840dbbdc21662f37001 to your computer and use it in GitHub Desktop.
Move Final Renderings value to Shared for Standard Values
$results = @();
foreach ( $item in Get-ChildItem -Recurse )
{
if ($item.Name -ne "__Standard Values") {
continue;
}
$result = New-Object System.Object
$result | Add-Member -type NoteProperty -name ID -value $item.ID
$result | Add-Member -type NoteProperty -name Path -value $item.FullPath
$result | Add-Member -type NoteProperty -name Shared -value 0
$result | Add-Member -type NoteProperty -name Final -value 0
$result | Add-Member -type NoteProperty -name BothSame -value 0
$result | Add-Member -type NoteProperty -name BothDifferent -value 0
$result | Add-Member -type NoteProperty -name Neither -value 0
if ($item.__Renderings -ne "") {
$result.Shared = 1;
}
if ($item."__Final Renderings" -ne "") {
$result.Final = 1;
}
$result.BothSame = ($result.Shared -band $result.Final) -band ($result.__Renderings -eq $result."__Final Renderings")
$result.BothDifferent = ($result.Shared -band $result.Final) -band ($result.__Renderings -ne $result."__Final Renderings")
$result.Neither = !$result.Shared -band !$result.Final
if (!$result.Shared -and $result.Final)
{
Write-Host "Moving Final Layout to Shared for $($item.FullPath)"
$item.__Renderings = $item."__Final Renderings";
Reset-ItemField -Item $item -IncludeStandardFields -Name "__Final Renderings"
}
elseif ($result.BothSame)
{
Write-Host "Resetting Final Layout for $($item.FullPath)"
Reset-ItemField -Item $item -IncludeStandardFields -Name "__Final Renderings"
}
$results += $result
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment