This script can retrieve document versions, along with metadata such as the version number, last modified date, and the user who made the changes.
This PowerShell script will,
- Connect to a SharePoint site.
- Access a specified document library.
- Retrieve version information for each document, including version number, modified date, and modified by.
- Export the data to a CSV file for easy reference.
Step 1. Install PnP.PowerShell module.
Install-Module -Name "PnP.PowerShell" -Scope CurrentUser.
Step 2. Script to get all the versions of Documents.
Notes
- This script leverages PnP.PowerShell, the modern module that replaces the legacy SharePointPnPPowerShellOnline.
- The password is securely handled by converting it to a SecureString and using it within the PSCredential object.
Conclusion
This approach provides a simple and modern way to retrieve document version histories using PnP.PowerShell, with added security and cross-platform compatibility.