How to Copy a Specific SharePoint File Version with PnP PowerShell
Question details
The user needs to copy the published version of a SharePoint file, regardless of its current draft or pending status, using PnP PowerShell.

- Product
- SharePoint / PnP PowerShell
- Device & OS
- not provided
- Scenario
- Attempting to copy specific file versions across SharePoint document libraries where strict content approval and versioning are enabled.
- Observed behavior
- The standard Copy-PnPFile command skips files that are currently in a draft state, even when the user has access, preventing the successful duplication of the desired published version.
Ensure you have the latest PnP PowerShell module installed and that your account possesses sufficient SharePoint site permissions to read all document versions and draft items.
Use a Custom PnP PowerShell Script to Fetch the Specific Version
Because standard copy commands often skip draft files, utilizing a custom script allows you to explicitly retrieve and download the required published version from the file's history.
When SharePoint content approval is active, the Copy-PnPFile cmdlet may behave unpredictably with files in draft or pending states. To bypass this limitation, you can interact directly with the file's version collection to extract the exact data stream you need.
Open your PowerShell console and execute 'Connect-PnPOnline -Url <YourSiteUrl> -Interactive' to securely authenticate with your SharePoint site.
Use the 'Get-PnPFile -Url <YourFileUrl> -Includes Versions' command to fetch the file object along with its complete version history.
Access the '.Versions' property on the retrieved file object to loop through the historical records and identify the exact published version you need based on its version label.
Once the target version is identified, use the specific PnP download commands or the file stream properties to save the version's contents locally before uploading it to the new destination.

Seamlessly Edit Your Downloaded SharePoint Documents with WPS Office
After retrieving your specific SharePoint document versions via PowerShell, you need a reliable suite to open, view, and edit them. WPS Office provides a lightweight, highly compatible, and free alternative to Microsoft Office.
- 1. Download WPS Office: Visit the official WPS website to download the free installation package tailored for your operating system.
- 2. Install the Suite: Run the downloaded installer file and follow the simple on-screen instructions to complete the setup.
- 3. Open Your Documents: Launch WPS Office and instantly open your downloaded SharePoint file versions for seamless editing and review.

Frequently Asked Questions
Why does Copy-PnPFile skip certain documents during the copy process?
When SharePoint content approval and versioning are strictly enabled, the Copy-PnPFile command may skip files that are currently in draft or pending status, as it primarily targets default published versions.
How can I find the exact version number of a SharePoint file using PowerShell?
You can use the Get-PnPFile command along with the -Includes Versions parameter to retrieve the file object, and then iterate through its .Versions property to view the specific version labels and IDs.
Where can I get help writing custom PnP PowerShell scripts?
For detailed scripting assistance and complex version retrieval logic, you can post your specific scenario and script attempts in the Microsoft Q&A forums for expert community support.




