SHARE
TWEET

Untitled

a guest Jan 21st, 2019 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $masterdatabase = "master"
  2. $webdatabase = "web"
  3. $root = Get-Item -Path (@{$true="$($masterdatabase):\content\home"; $false="$($masterdatabase):\content"}[(Test-Path -Path "$($masterdatabase):\content\home")])
  4.  
  5.  
  6. $props = @{
  7.     Parameters = @(
  8.         @{Name="root"; Title="Choose the report root"; Tooltip="Only items from this root will be returned."; }
  9.             )
  10.     Title = "comparison Report"
  11.     Description = "Choose the criteria for the report."
  12.     Width = 550
  13.     Height = 300
  14.     ShowHints = $true
  15.     Icon = [regex]::Replace($PSScript.Appearance.Icon, "Office", "OfficeWhite", [System.Text.RegularExpressions.RegexOptions]::IgnoreCase)
  16. }
  17.  
  18. $result = Read-Variable @props
  19.  
  20. if($result -eq "cancel") {
  21.     exit
  22. }
  23.  
  24. filter Where-comparereport {
  25.     param(
  26.         [Parameter(Mandatory=$true,ValueFromPipeline=$true)]
  27.         [Sitecore.Data.Items.Item]$item
  28.     )
  29.    
  30.     if ($item) {
  31.         $masteritem = $item.Versions.GetLatestVersion().Version.Number
  32.        
  33.         $webitem = [Sitecore.Data.Database]::GetDatabase("web").GetItem($item.Id)
  34.         if($webitem){
  35.        
  36.         $webitemnumber = $webitem.Versions.GetLatestVersion().Version.Number
  37.        
  38.         if (!$masteritem.Equals($webitemnumber)) {
  39.             $item
  40.         }
  41.         }
  42.     }
  43. }
  44.  
  45. $items = @($root) + @(($root.Axes.GetDescendants() | Initialize-Item)) | Where-comparereport
  46.  
  47. if($items.Count -eq 0) {
  48.     Show-Alert "There are no content items that is different from web and master database"
  49. } else {
  50.     $props = @{
  51.         Title = "Item versions difference Report"
  52.         InfoTitle = "Items that the latest version on web db is different than master"
  53.         InfoDescription = "Items that the latest version on web db is different than master"
  54.         PageSize = 25
  55.     }
  56.    
  57.     $items |
  58.         Show-ListView @props -Property @{Label="Icon"; Expression={$_.__Icon} },
  59.             @{Label="Name"; Expression={$_.DisplayName} },
  60.             @{Label="Updated"; Expression={$_.__Updated} },
  61.             @{Label="Updated by"; Expression={$_."__Updated by"} },
  62.             @{Label="Created"; Expression={$_.__Created} },
  63.             @{Label="Created by"; Expression={$_."__Created by"} },
  64.             @{Label="Path"; Expression={$_.ItemPath} }
  65. }
  66.  
  67. Close-Window
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top