Description
Expected behavior
PnP-RemoveFileVersion
is able to process encoded URLs
Actual behavior
Remove-PnPFileVersion
errors if the URL provided contains any encoded characters, e.g. %20
instead of ' '
Steps to reproduce behavior
-
Get link to file from UI or other means and save relative url, for example:
https://contoso.sharepoint.com/sites/test/Shared%20Documents/Test%20document.docx
$SiteUrl = "https://contoso.sharepoint.com/sites/test"
$FileUrl = "Shared%20Documents/Test%20document.docx"
-
Connect to SharePoint and validate file URL
Connect-PnPOnline -Url $SiteUrl
(PnP-GetFile $FileUrl).Id
> 1234 (Success)
-
Try to delete file versions
PnP-RemoveFileVersion -All -Force -Url $FileUrl
=> PnP-RemoveFileVersion -All -Force -Url "Shared%20Documents/Test%20document.docx"
> Remove-PnPFileVersion: File not found (Error)
-
Try to delete file versions with decoded URL
$FileUrl = [System.Web.HttpUtility]::UrlDecode($FileUrl)
PnP-RemoveFileVersion -All -Force -Url $FileUrl
=> PnP-RemoveFileVersion -All -Force -Url "Shared Documents/Test document.docx"
> (Success)
What is the version of the Cmdlet module you are running?
2.12.0
Which operating system/environment are you running PnP PowerShell on?
- Windows