Set-PnPUnifiedGroup -Owners should set the owners based on UPNs provided.
In the docs:
"The array UPN values of owners to set to the group. Note: Will replace owners."
Expected behavior
Connect-PnPOnline -Scopes "Directory.ReadWrite.All", "Group.ReadWrite.All", "User.Read.All"
$group = Get-PnPMicrosoft365Group -Identity $siteInfo.GroupId.Guid
$newOwners = "cjordan@foo.com", "kdochney@foo.com", "marc.anderson@foo.com"
Clear-PnPMicrosoft365GroupOwner -Identity $group # Removes all but one Owner and throws an error
Set-PnPUnifiedGroup -Identity $group -Owners $newOwners -Members $newOwners
I expect the three users to be added a both Owners and Members.
Also see: #2820
Actual behavior
If one or more of the UPNs provided are already Owners, this is the error. Based on the docs, I expect all three users to replace whomever is already there.
Set-PnPUnifiedGroup : Code: Request_BadRequest
Message: One or more added object references already exist for the following modified properties: 'owners'.
Inner error
At D:\code\Denholtz\Deployment\PowerShell\ReApplyPnPProvisioningTemplate.ps1:37 char:5
+ Set-PnPUnifiedGroup -Identity $group -Owners $newOwners -Members ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (PnP.PowerShell....crosoft365Group:SetMicrosoft365Group) [Set-PnPMicrosoft365Group], ServiceException
+ FullyQualifiedErrorId : GROUPUPDATEFAILED,PnP.PowerShell.Commands.Graph.SetMicrosoft365Group
Steps to reproduce behavior
See above
Which version of the PnP-PowerShell Cmdlets are you using?
[ ] PnP PowerShell for SharePoint 2013
[ ] PnP PowerShell for SharePoint 2016
[ ] PnP PowerShell for SharePoint 2019
[X] PnP PowerShell for SharePoint Online
What is the version of the Cmdlet module you are running?
3.24.2008.0
How did you install the PnP-PowerShell Cmdlets?
[ ] MSI Installed downloaded from GitHub
[X] Installed through the PowerShell Gallery with Install-Module
Reporting an Issue or Missing Feature
Set-PnPUnifiedGroup -Owners
should set the owners based on UPNs provided.In the docs: "The array UPN values of owners to set to the group. Note: Will replace owners."
Expected behavior
I expect the three users to be added a both Owners and Members.
Also see: #2820
Actual behavior
If one or more of the UPNs provided are already Owners, this is the error. Based on the docs, I expect all three users to replace whomever is already there.
Steps to reproduce behavior
See above
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
3.24.2008.0
How did you install the PnP-PowerShell Cmdlets?