如何在 PowerShell 中创建来宾 AD 用户邀请,然后添加到 SharePoint Online 网站 [英] How to create guest AD user invitation then add to a SharePoint Online site in PowerShell
问题描述
此脚本创建来宾用户邀请,但在尝试将该新创建的用户添加到 SharePoint Online 网站时出错,并显示以下错误:
This script creates a guest user invitation, but errors when trying to add that newly created user to a SharePoint Online site with the following error:
Add-SPOUser:找不到指定的用户 janedoe@email.com.
$tenant = "companyname"
Connect-SPOService -url "https://$tenant-admin.sharepoint.com"
Connect-AzureAD -TenantDomain "$tenant.onmicrosoft.com"
New-AzureADMSInvitation -InvitedUserDisplayName "Jane Doe" -InvitedUserEmailAddress "janedoe@email.com" -InviteRedirectURL "https://$tenant.sharepoint.com/sites/client1" -SendInvitationMessage $true
Start-Sleep -s 60
Add-SPOUser -Group "Client Site 1 Visitors" –LoginName "janedoe@email.com" -Site "https://$tenant.sharepoint.com/sites/client1"
Disconnect-SPOService
Disconnect-AzureAD
Azure AD 将该用户填充到 Office 365 需要多长时间?
How long does it take for Azure AD to populate that user into Office 365?
推荐答案
当尝试通过 GUI 将外部用户电子邮件(外部租户)添加到 SP 组时,移开会显示以下错误:
When trying to add the external user email (outside tenancy) to a SP group via the GUI, tabbing away shows the following error:
您组织的政策不允许您与这些用户共享.转到 Office 365 管理中心中的外部共享以启用它."
要解决此问题和 PS 脚本错误,请在创建 Extranet SP 站点后,在连接到 SPO 后运行以下 PS 命令(只需在将外部用户添加到站点之前运行 ONCE):
To fix this and the PS script error, after the creation of your extranet SP site run the following PS command after connecting to SPO (only need to run ONCE before adding an external user to a site):
Set-SPOSite -identity https://companyname.sharepoint.com/sites/client1 -sharingcapability ExternalUserAndGuestSharing
现在 PS 脚本可以正常工作了.不需要开始睡眠.
Now the PS script will work without error. Start-Sleep is not necessary.
这篇关于如何在 PowerShell 中创建来宾 AD 用户邀请,然后添加到 SharePoint Online 网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!