Skip to content

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

Open
@gaiking-uk

Description

@gaiking-uk

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions