pnp / powershell

PnP PowerShell
https://pnp.github.io/powershell
MIT License
683 stars 348 forks source link

[BUG] Cannot create a M365 group with an apostrophe / single quote in the display name with `New-PnPMicrosoft365Group` #4545

Open lapin-b opened 4 days ago

lapin-b commented 4 days ago

Reporting an Issue or Missing Feature

Issue similar to #4169 where quotes are not properly accounted for in the query.

Expected behavior

When the cmdlet is invoked with a group display name containing an apostrophe / single quote, the M365 group is not created and the cmdlet errors out with the following message instead:

New-PnPMicrosoft365Group: 
Line |
  98 |  $group = New-PnPMicrosoft365Group -DisplayName $teamName -Description …
     |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     | Bad Request (400): Invalid filter clause: ')' or operator expected at position 69 in 'groupTypes/any(c:c eq 'Unified') and (displayName eq 'L'apostrophe' or mailNickName eq 'L'apostrophe')'.

(I replaced the actual group name with a dummy one, the position might not be exact)

Actual behavior

I would expect a successful run and the creation of a M365 group with a Microsoft Teams team associated (flag -CreateTeam).

Steps to reproduce behavior

  1. Authenticate to the tenant with Connect-PnPOnline (how precisely shouldn't matter)
  2. Invoke New-PnPMicrosoft365Group with a display name containing quotes
  3. See the HTTP 400 Bad Request error being reported

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

PnP.PowerShell version 2.12.0 on PowerShell 7.2

Which operating system/environment are you running PnP PowerShell on?

gautamdsheth commented 12 hours ago

@lapin-b - can you please try with the latest nightly builds and let us know, I couldn't reproduce it at my end ?