将office365组添加到Sharepoint网站集管理员thorugh Powershell

将office365组添加到Sharepoint网站集管理员thorugh Powershell,powershell,sharepoint,office365,sharepoint-online,azure-automation,Powershell,Sharepoint,Office365,Sharepoint Online,Azure Automation,我正试图通过PowerShell或API将office 365组中的一个添加为SharePoint online站点中的网站集管理员,但我没有得到任何解决方案。 我可以从站点用户界面手动执行,但我想自动执行,因此需要寻找Powershell或API。 您可以使用PnP PowerShell cmdlet添加PnPSiteCollectionAdmin-owners 参考: 我们需要注意的是,与文档中所说的不同,我们需要使用LoginName像i:0.f|membership一样|user1@co

我正试图通过PowerShell或API将office 365组中的一个添加为SharePoint online站点中的网站集管理员,但我没有得到任何解决方案。 我可以从站点用户界面手动执行,但我想自动执行,因此需要寻找Powershell或API。

您可以使用PnP PowerShell cmdlet
添加PnPSiteCollectionAdmin-owners

参考:

我们需要注意的是,与文档中所说的不同,我们需要使用
LoginName
i:0.f|membership一样|user1@contoso.sharepoint.com

因此,对于O365组,它应该类似于
c:0o.c | federateddirectoryclaimprovider |

对于安全组,它应类似于
c:0t.c |租户|

您可以在Azure AD中获取组的对象ID。

我收到此错误“尝试添加用户时发生异常:”找不到指定的用户c:0o.c|federateddirectoryclaimprovider***********-461f-bcaf-51235ee3369b。“。将跳过用户。”通过,我已经输入了正确的组ID。我正在添加一个安全组它对我有效我使用了c:0t.c | tenant |@amy很高兴听到你完成了它。是,O365组和安全组不同,您需要有不同的前缀。我会在我的回复中更新你的答案,请接受它作为答案