pnp / PnP-PowerShell

SharePoint PnP PowerShell CmdLets
https://pnp.github.io/powershell
Other
987 stars 665 forks source link

Add-PnPFolder fails for folder names containing an ampersand (&) #2413

Closed hinek closed 4 years ago

hinek commented 4 years ago

Reporting an Issue or Missing Feature

Issue

Expected behavior

For SharePoint Online, Add-PnPFolder should be able to create a folder, that contains an ampersand (&). You can create a folder like this using UI and using Resolve-PnPFolder.

Actual behavior

Cmdlet fails with the following error message: Add-PnPFolder : The argument must be a single folder name and cannot contain path characters. Parametername: folderName

Steps to reproduce behavior

Add-PnPFolder -Name "Test & Repeat" -Folder "Shared Documents"
Add-PnPFolder : The argument must be a single folder name and cannot contain path characters.
Parametername: folderName
In Zeile:1 Zeichen:1
+ Add-PnPFolder -Name "Test & Repeat" -Folder "Shared Documents"
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (:) [Add-PnPFolder], ArgumentException
    + FullyQualifiedErrorId : EXCEPTION,SharePointPnP.PowerShell.Commands.Files.AddFolder

Resolve-PnPFolder -SiteRelativePath "Shared Documents/Test & Repeat"

Name          Type   Items/Size Last Modified
----          ----   ---------- -------------
Test & Repeat Folder          0

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

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

3.16.1912.0

How did you install the PnP-PowerShell Cmdlets?

ghost commented 4 years ago

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

danielcecil commented 4 years ago

Hi, I couldn't reproduce this error in SPO. Looking through the code the exception should only be thrown if the Name includes any of these characters: [""#%*:<>?/\|\t\r\n]. Note that in SharePoint on-premises the ampersand is not allowed: [~#%&*{}\:<>?/|""\t\r\n].

Have you tried escaping the ampersand, e.g. "Test `& Repeat"

hinek commented 4 years ago

Thank you, escaping like in your example did the trick.

tomka75 commented 4 years ago

Using a "&" in a provisioning template, produces the same error. Escaping like "%26" … does not help. Creating the folder manually in SharePoint Online and than calling Get-PnPListItem -List "12345" retrieves a blank title.