Get document wise versions list using Powershell

function Get-DocumentItemVersionsList([string]$WebURL, [String[]]$listName)
{
[void][System.reflection.Assembly]::LoadWithPartialName(“Microsoft.SharePoint”)

set-variable -option constant -name out -value “C:\Get-ListItemVersionsList_Output.csv”
“Item_ID|Item Title|Item URL|Version Count” | Out-File $out -Append

write-host “–IN”
$web = get-spweb $WebURL
write-host “–Web initiated”
$list = $web.Lists.TryGetList($listName)
write-host “–List initiated”
$listItems = $list.Items;

write-host “–List Items Count = ” $listItems.Count

foreach($item in $listItems)
{
$itemTitle = $item[“Name”]
$itemURL = $item.Url
$itemID = [string]$item.Id
$itemVersCount = $item.Versions.Count

#write-host “–List Item – ” $itemTitle ” Versions – ” $itemVersCount
#$itemTitle + “|” + $itemVersCount + “|” | Out-File $out -Append

if($itemVersCount -gt 1)
{
$itemID + “|” + $itemTitle + “|” + $itemURL + “|” + $itemVersCount | Out-File $out -Append

}
}

$web.Dispose()
}

Get-DocumentItemVersionsList -WebURL:’http://user.company.com/hr/’ -listName:’Shared Documents’

NGenious Solutions