【问题标题】:How to add AAD Group as SharePoint Online visitors如何将 AAD 组添加为 SharePoint Online 访问者
【发布时间】:2020-05-15 10:00:38
【问题描述】:

我可以使用此命令将 O365 组添加为 SharePoint 网站访问者

Add-SPOUser -Site 'https://xxx.sharepoint.com/sites/testsite01 -LoginName testgroup01@xxx.onmicrosoft.com -Group 'testsite01 Visitors'

我要将 AAD 组添加为 SharePoint 网站访问者,我通过以下命令找到了 AAD 组 GUID:

Get-AzureADGroup  -SearchString testgroup01 | Select DisplayName, ObjectID

然后我使用此命令添加 AAD 组(我已确认 GUID 有效)

Add-SPOUser -Site 'https://xxx.sharepoint.com/sites/testsite01 -LoginName 'c:0t.c|tenant|af143a4a-f7f0-430c-b83b-c9b5dxxx2ef' -Group 'testsite01 Visitors'

错误信息:

Add-SPOUser : Group cannot be found.
At line:1 char:1
+ Add-SPOUser -Site 'https://xxx.sharepoint.com/sites/testsite01
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Add-SPOUser], ServerException
    + FullyQualifiedErrorId : Microsoft.SharePoint.Client.ServerException,Microsoft.Online.SharePoint.PowerShell.AddSPOUser

谁能告诉我怎么了?谢谢!!

【问题讨论】:

    标签: powershell sharepoint-online


    【解决方案1】:

    您可以尝试 PnP PowerShell 将 Office 365 组添加到 SharePoint 组。

    #region Variables 
    $Username = "admin@xxx.onmicrosoft.com" 
    $Password = "password" 
    $siteURL = "https://xxx.sharepoint.com/sites/modernteam" 
    #endregion Variables
    
    #region Credentials 
    [SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force 
    [System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass) 
    #endregion Credentials
    
    Connect-PnPOnline -Url $siteURL -Credentials $PSCredentials   
    Add-PnPUserToGroup -LoginName GroupLee@xxx.onmicrosoft.com -Identity 'modernteam Visitors'
    Write-Host "---"
    

    【讨论】:

    • 我需要 AAD 组(从 AD 同步)
    猜你喜欢
    • 1970-01-01
    • 2014-01-04
    • 2018-07-12
    • 1970-01-01
    • 2019-10-23
    • 2019-09-11
    • 2014-07-25
    • 1970-01-01
    • 2016-11-13
    相关资源
    最近更新 更多