pnp / PnP-PowerShell

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

Clear-PnPMicrosoft365GroupOwner Throws Error and Doesn't Clear All Owners #2820

Open sympmarc opened 4 years ago

sympmarc commented 4 years ago

Expected behavior

Running Clear-PnPMicrosoft365GroupOwner -Identity $group should (as the docs state) clear all existing Group Owners

Actual behavior

Groups can't have zero owners, so the cmdlet deletes all but one owner and throws this error:

Clear-PnPMicrosoft365GroupOwner : One or more errors occurred.
At line:3 char:1
+ Clear-PnPMicrosoft365GroupOwner -Identity $group
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Clear-PnPMicrosoft365GroupOwner], AggregateException
    + FullyQualifiedErrorId : System.AggregateException,SharePointPnP.PowerShell.Commands.Graph.ClearMicrosoft365GroupOwner

The remaining owner is not predictable. Last added, maybe?

Steps to reproduce behavior

Connect-PnPOnline -Scopes "Directory.ReadWrite.All","Group.ReadWrite.All"
$group = Get-PnPMicrosoft365Group -Identity $groupName # Where $groupName is the display name of a Group in your tenant
Clear-PnPMicrosoft365GroupOwner -Identity $group

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

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

3.23.2007.1

How did you install the PnP-PowerShell Cmdlets?