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’

About Vishal Geet

Experienced Senior Technical Project Manager with a demonstrated history of working in the information technology and services industry. Skilled in SharePoint Technology, Requirements Analysis, Oracle Database, IT Strategy, Project Management and Data Warehousing.

View all posts by Vishal Geet →

Leave a Reply

Your email address will not be published.

eighteen − one =