Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] PnP-RemoveFileVersion fails if URL contains encoded characters #4723

Open
1 task done
gaiking-uk opened this issue Feb 4, 2025 · 0 comments
Open
1 task done
Labels
bug Something isn't working

Comments

@gaiking-uk
Copy link

gaiking-uk commented Feb 4, 2025

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

  1. 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"

  2. Connect to SharePoint and validate file URL
    Connect-PnPOnline -Url $SiteUrl
    (PnP-GetFile $FileUrl).Id
    > 1234 (Success)

  3. 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)

  4. 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
@gaiking-uk gaiking-uk added the bug Something isn't working label Feb 4, 2025
@gaiking-uk gaiking-uk changed the title [BUG] PnP-RemoveFileVersion [BUG] PnP-RemoveFileVersion fails if URL contains encoded characters Feb 4, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant