Skip to main content
added 27 characters in body
Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

You can use below snippet to fetch archived items from database along with version numbers and count as below.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive",$database)

#browse#fetch archive entries from page index as zero0 and page size as 100.
$archiveEntries = $archiveManager.GetEntries(0,100);

$arrayOfArchivedItems = @()
$archiveEntries | ForEach {
    $version$itemVersions = $archiveManager.GetVersions($_.ItemId)
    
    $itemVersions$itemVersionNumbers = @()
    $version$itemVersions | ForEach {
        $itemVersions$itemVersionNumbers += $_.Version
    }
    
    $itemVersionSorted = $itemVersions$itemVersionNumbers | Sort-Object
    
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member -Name 'Name' -MemberType Noteproperty -Value  $_.OriginalLocation
    $obj | Add-Member -Name 'VersionNumbers' -MemberType Noteproperty -Value  $itemVersionSorted
    $obj | Add-Member -Name 'VersionCount' -MemberType Noteproperty -Value  $itemVersionSorted.Count
    $arrayOfArchivedItems += $obj
}

$arrayOfArchivedItems | Format-Table

This returns the output as below containing item path, version numbers archived and count of versions archived.

enter image description here

Using similar way you can fetch details of recycle bin as well by setting the archive manager as below to fetch from 'recyclebin'.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("recyclebin",$database)

Hope this helps!!!

You can use below snippet to fetch archived items from database along with version numbers and count as below.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive",$database)

#browse archive entries from page index as zero and page size as 100.
$archiveEntries = $archiveManager.GetEntries(0,100);

$arrayOfArchivedItems = @()
$archiveEntries | ForEach {
    $version = $archiveManager.GetVersions($_.ItemId)
    
    $itemVersions = @()
    $version | ForEach {
        $itemVersions += $_.Version
    }
    $itemVersionSorted = $itemVersions | Sort-Object
    
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member -Name 'Name' -MemberType Noteproperty -Value  $_.OriginalLocation
    $obj | Add-Member -Name 'VersionNumbers' -MemberType Noteproperty -Value  $itemVersionSorted
    $obj | Add-Member -Name 'VersionCount' -MemberType Noteproperty -Value  $itemVersionSorted.Count
    $arrayOfArchivedItems += $obj
}

$arrayOfArchivedItems | Format-Table

This returns the output as below containing item path, version numbers archived and count of versions archived.

enter image description here

Using similar way you can fetch details of recycle bin as well by setting the archive manager as below to fetch from 'recyclebin'.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("recyclebin",$database)

Hope this helps!!!

You can use below snippet to fetch archived items from database along with version numbers and count as below.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive",$database)

#fetch archive entries from page index 0 and page size 100.
$archiveEntries = $archiveManager.GetEntries(0,100);

$arrayOfArchivedItems = @()
$archiveEntries | ForEach {
    $itemVersions = $archiveManager.GetVersions($_.ItemId)
    
    $itemVersionNumbers = @()
    $itemVersions | ForEach {
        $itemVersionNumbers += $_.Version
    }
    
    $itemVersionSorted = $itemVersionNumbers | Sort-Object
    
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member -Name 'Name' -MemberType Noteproperty -Value  $_.OriginalLocation
    $obj | Add-Member -Name 'VersionNumbers' -MemberType Noteproperty -Value  $itemVersionSorted
    $obj | Add-Member -Name 'VersionCount' -MemberType Noteproperty -Value  $itemVersionSorted.Count
    $arrayOfArchivedItems += $obj
}

$arrayOfArchivedItems | Format-Table

This returns the output as below containing item path, version numbers archived and count of versions archived.

enter image description here

Using similar way you can fetch details of recycle bin as well by setting the archive manager as below to fetch from 'recyclebin'.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("recyclebin",$database)

Hope this helps!!!

Source Link
ckhanna
  • 3.7k
  • 1
  • 1
  • 12

You can use below snippet to fetch archived items from database along with version numbers and count as below.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("archive",$database)

#browse archive entries from page index as zero and page size as 100.
$archiveEntries = $archiveManager.GetEntries(0,100);

$arrayOfArchivedItems = @()
$archiveEntries | ForEach {
    $version = $archiveManager.GetVersions($_.ItemId)
    
    $itemVersions = @()
    $version | ForEach {
        $itemVersions += $_.Version
    }
    $itemVersionSorted = $itemVersions | Sort-Object
    
    $obj = New-Object -TypeName PSObject
    $obj | Add-Member -Name 'Name' -MemberType Noteproperty -Value  $_.OriginalLocation
    $obj | Add-Member -Name 'VersionNumbers' -MemberType Noteproperty -Value  $itemVersionSorted
    $obj | Add-Member -Name 'VersionCount' -MemberType Noteproperty -Value  $itemVersionSorted.Count
    $arrayOfArchivedItems += $obj
}

$arrayOfArchivedItems | Format-Table

This returns the output as below containing item path, version numbers archived and count of versions archived.

enter image description here

Using similar way you can fetch details of recycle bin as well by setting the archive manager as below to fetch from 'recyclebin'.

$database = [Sitecore.Configuration.Factory]::GetDatabase("master")
$archiveManager = [Sitecore.Data.Archiving.ArchiveManager]::GetArchive("recyclebin",$database)

Hope this helps!!!