Skip to content
This repository was archived by the owner on Jan 19, 2021. It is now read-only.

Remove-PNPFile has problems with special characters # and % #1766

Open
4 tasks
dkkazak opened this issue Nov 8, 2018 · 1 comment
Open
4 tasks

Remove-PNPFile has problems with special characters # and % #1766

dkkazak opened this issue Nov 8, 2018 · 1 comment

Comments

@dkkazak
Copy link

dkkazak commented Nov 8, 2018

###Notice: many issues / bugs reported are actually related to the PnP Core Library which is used behind the scenes. Consider carefully where to report an issue:###

  1. Are you using Apply-SPOProvisioningTemplate or Get-SPOProvisioningTemplate? The issue is most likely related to the Provisioning Engine. The Provisioning engine is not located in the PowerShell repo. Please report the issue here: https://github.com/officedev/PnP-Sites-Core/issues.
  2. Is the issue related to the cmdlet itself, its parameters, the syntax, or do you suspect it is the code of the cmdlet that is causing the issue? Then please continue reporting the issue in this repo.
  3. If you think that the functionality might be related to the underlying libraries that the cmdlet is calling (We realize that that might be difficult to determine), please first double check the code of the cmdlet, which can be found here: https://github.com/OfficeDev/PnP-PowerShell/tree/master/Commands. If related to the cmdlet, continue reporting the issue here, otherwise report the issue at https://github.com/officedev/PnP-Sites-Core/issues

Reporting an Issue or Missing Feature

Please confirm what it is that your reporting
When trying to remove a file with a # or a %, the lookup fails.

Expected behavior

Please describe what output you expect to see from PnP-PowerShell Cmdlets
$FileToDelete = "/sites/teamTest/Shared Documents/Infrastructure/1#1.jpg"
Remove-PnPFile -ServerRelativeUrl $FiletoDelete -Recycle

Running the above, I would expect it to delete the file as requested.

Actual behavior

Please describe what you see instead. Please provide samples of HTML output or screenshots
Here is what I run:
$FileToDelete = "/sites/teamTest/Shared Documents/Infrastructure/1#1.jpg"
Remove-PnPFile -ServerRelativeUrl $FiletoDelete -Recycle

When I run this, I get the following:
Confirm
Delete '1'?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y

You'll notice that it stops processing the file name at the # and is therefore unable to find the file to delete it. (If the filename is #1.jpg , then it ends up deleting the whole folder which I found out painfully.)

When I ran across this, I decided to do some more testing. Here is what I discovered:

Filename | Return Output | Allowed in NTFS
Filename | Return Output
1#1.jpg | 1
1%1.jpg | 1%251.jpg
1+1.jpg | 1+1.jpg
1,1.jpg | 1,1.jpg
1&1.jpg | 1&1.jpg

You can see that it appears to be an issue with # and % (where it adds additional characters).

Steps to reproduce behavior

Please include complete code samples in-line or linked from gists
$FileToDelete = "/sites/teamTest/Shared Documents/Infrastructure/1#1.jpg"
Remove-PnPFile -ServerRelativeUrl $FiletoDelete -Recycle

Which version of the PnP-PowerShell Cmdlets are you using?

  • PnP PowerShell for SharePoint 2013
  • PnP PowerShell for SharePoint 2016
  • [X ] PnP PowerShell for SharePoint Online 1810

What is the version of the Cmdlet module you are running?

(you can retrieve this by executing Get-Module -Name *pnppowershell* -ListAvailable)
3.2.1810.0

How did you install the PnP-PowerShell Cmdlets?

  • MSI Installed downloaded from GitHub
  • [ X] Installed through the PowerShell Gallery with Install-Module
  • Other means
@nalhemyariirexorg
Copy link

Having the same issue, where you able to find a working solution?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants