- 1 Export SharePoint Version History to Excel
- 2 What’s SPDocVersion-Exporter?
In this post, we’re gonna introduce a new PowerShell Script “SPDocVersion-Exporter” that would help you to Export SharePoint Version History Details with Comments for all documents in a specific SharePoint Document Library using PowerShell.
Consider you have a SharePoint Document Library that holds several documents
In this SharePoint document Library, the Document Version History and Checked-Out settings has been enabled as shown below:
Now, if you need to show the Version History details for specific document, so you can easily select this document and from the File tab, click on Version History.
Alternatively, you can also explore the SharePoint Document Versions History as below:
Regardless, the method that you will use to show the SharePoint Document Versions History, consider, you have several documents and you need to show and export the Versions History for all documents in one view!
In this case, I think it will be a silly task to manually show the version details history for each document one by one! Also, there is no Export to Excel option to export the version history details for each document as shown below!
So that, our main goal in this post is to overcome such SharePoint limitations by introducing a well-written and tested PowerShell script “SPDocVersion-Exporter” that would help you to export all SharePoint document versions history details for each document in a SharePoint document library with just a push of a button.
The SPDocVersion-Exporter is a PowerShell Script to export the document version history details for all documents in a specific SharePoint Document Library to Excel\CSV file.
Note: This script was previously published on TechNet Gallery in 2017 and was improved upon and published on PowerShell Gallery in 2021.
The SPDocVersion-Exporter script was tested on multiple farms that have the following SharePoint versions installed:
- SharePoint 2019.
- SharePoint 2016.
- SharePoint 2013.
Below, we’re gonna list the main features and capabilities of SPDocVersion-Exporter PowerShell Script:
- Get all document details like
- Document ID,
- Document Name,
- Document URL,
- Total number of versions,
- Created By,
- Created Date,
- Modified By,
- Modified Date,
- File Size.
- Show all version history details with comments for each document like
- Version ID,
- Version Title,
- Modified By,
- Modified Date,
- Version Size,
- Check-In Comment.
- Show the document details first then list all related version details.
- Show the detailed steps for each document.
- Show a summary of the export operation.
- Get the total number of all documents in SharePoint Document Library.
- Get the count of all versions in SharePoint Document Library.
Validation and Verification
- Perform validation and verification for the SharePoint Site URL, the Document Library Name, and the Exported file Path.
- It also checks if the version settings for a document library have been enabled or not before proceed.
If the versioning setting is not enabled, the script will automatically open the Document Library Versioning Settings to enable it.
- Build an independent folder for each document library.
- Organize each result in a particular file classified by the current date and time.
- Don’t overwrite old files.
The SPDocVersion-Exporter provides you two options to export SharePoint Version History :
- Export the version history for ALL documents.
- Export the version history for a particular document.
Easy to use
- No additional configuration on your side, you only need to install SPDocVersion-Exporter script from PowerShell Gallery,
- Provides only two parameters (SharePoint Site URL, Document Library Name).
- Type “All” to export SharePoint Version History for all documents or paste the “document URL” to export a specific document version.
- Once the script is run successfully, the exported file will be opened automatically to show the result.
How to use SPDocVersion-Exporter?
To export SharePoint Document Library Version Details to Excel using “SPDocVersion-Exporter”, you should do the following:
- Open the Windows PowerShell As administrator.
- Type the below cmdlet to install the “SPDocVersion-Exporter” script.
Install-Script -Name SPDocVersion-Exporter
Note: Install-Script runs on PowerShell 5.0 or later releases, for more details, Please check The term ‘Install-Module’ is not recognized
If you don’t have an internet connection on your server, you can manually download the .nupkg file, and install it as mentioned in the Manual Package Download
If you already installed the “SPDocVersion-Exporter” script, and you would like to get the latest version, so you will need to reinstall the script again with the -force
Ex: Install-Script -Name SPDocVersion-Exporter -force
- After installing the script, type the below cmdlet to run it.
- The script will ask you to provide the below parameter values:
- siteURL: SharePoint Site that holds the document library.
- DocLibName: the document library display name (without quotation)
- Provide the correct SharePoint Site URL and Document Library name, then click Enter to run the script.
- you will be asked if you would like to export version history for all documents or for a particular document.
- Type All to export version history for all documents.
- Or paste the correct document URL.
- Now, the script should loop for each document in the specified SharePoint document library to export all document version history details to CSV file.
Where you can find the exported file location?
- The script will create a root folder in the “C:\” drive called “SPVersions”. In this folder, you will find a subfolder for each document library that holds another subfolder for each export operation for this document library
In case, you have ran this script again, it will create a new file in a new folder with the above structure.
- Inside, this folder, you will find the “Version.CSV” file.
- Once the script is run successfully, the CSV file should be opened automatically to show the exported data.
- Also, it will show a detailed summary for the exported document versions with the below info:
- Site URL: http://epm:19812/pmo/
- Site Title: deBUG.to
- Document Library Name: Doc Lib Get Versions Details
- Number of Documents: 2
- Number of Versions: 4
By default, the exported CSV file will not be formatted, and you can see the document details and its related versions as below.
So that, you just need to perform a bit manually format modifications to show the CSV file as below.
In the nearest future, we’re planning to add the below features to the “SPDocVersion-Exporter” PowerShell Script:
- Auto format for Excel Sheet.
- Support SharePoint Online.
- Filter by
- TopN or
- document name (done in version 1.5).
You can also add your suggestions and ideas on comments to enhance the SPDocVersion-Exporter.
The “SPDocVersion-Exporter” PowerShell Script is a well-written and tested script that helps you to easily export all document version details with comments for a specific SharePoint document library.
You might also like to read Backup all WSP SharePoint Solutions using PowerShell
1 thought on “Export SharePoint Version History to Excel Using PowerShell”
This is a great tool! If I had any “feature requests”, they would be:
1.) Allow an option to just export version information from a folder in the doc library
2.) Allow an option to export custom column information with the version information.