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.
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!!!