SharePoint listing all documents with versioning detail

Document library in SharePoint shows count of the documents only, but there are many minor and major versions for a document. In this blog post I am going to share how we can generate a report for a document library which have details for all major and minor versions of document version size and checkedIn comments.

You can check the size of document library using Storage Metrics but some time it does not show the exact size because its incremental only and always add the document version size to it, you need to reset it manually, check how to reset the SharePoint Storage Metrics size.

You can check the version details for any specific document by going to document version detail and check the version history with version detail, size, checked in comments and user who modified it.

SharePoint Document version history

Document library with large versions also slow down the performance of the document library, I am going to share a PowerShell script which will generate the versioning detail for a complete document library.

SharePoint Documents with versioning detail

The script will generate the report of a document library with all major and minor versions, it have a function named GetAllDocInventoryWithVerions which takes two parameters, the site URL and document library.

You can call the function output either in PowerShell gridview or in a CSV file. Run below cmdlet to execute the output in a gridview

To save the report in excel/csv, run the below command which will save the file at given location.

How to get CheckedIn comment

In above script, you need to get the checkedIn comment from the document version detail as Iisted in above script.

How to get Size for a specific version

Some time you want to know the size of a specific version, in above script I used the GetVersionsFromLabel method to get the size of a specific version. You can load any specific document using PowerShell and can get the version size.

Deleting document version using PowerShell

You can delete version directly from version history or using PowerShell script, powershell script will be helpful if you need to delete multiple versions.

$Ver here is the document version which I have looped in above script.

The following two tabs change content below.
Adnan Amin
Adnan is two time SharePoint MVP (Most Valuable Professional) with over 12 years of extensive experience with major expertise on SharePoint Server, Office 365, .Net Platform and Microsoft BI. He is currently working SharePoint Architect at FMT Consultants. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past nine years and worked on different intranet/intranet solutions for private & govt. sector majorly in Gulf region, which include OOB and customized solutions. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply