Requirement: Add External User to SharePoint Online using PowerShell.
How to add an External User in SharePoint Online?
SharePoint Online provides an excellent solution when you have to share any site, list, library, or document with users outside your organization such as vendors, clients, or partners. Before adding external users, we must ensure external sharing is enabled both at the tenant level and at site collection levels (Refer: How to Enable External Sharing in SharePoint Online?).
Add External User to SharePoint Online Site
How to give access to external users in SharePoint Online? Well, here are the steps to add external users to SharePoint Online: To share a SharePoint site with an external user(s),
- Login to your SharePoint Online site >> Click on the “Share” button from the top-right section of the page.
- In the Share site pane, Enter the Emails of External users, make sure the “Send email” checkbox is ticked, Optionally enter any message to the user and click on “Share” button the bottom. This triggers an Email to the external user with a link to accept the invitation.
SharePoint Online Add External User to Group
You can also go to the “Site Permissions” page from Site Settings >> Site Permissions and add external users to the SharePoint Online group or directly grant permission to external users.
Similar steps involved to share a document library or a file with external users. Just hover over any existing document and click on the “Share” icon.
Add Guest user to SharePoint Online site using PowerShell
Use this PowerShell script to add an external user to SharePoint Online site.
#Parameters $AdminCenterURL="https://CrescentIntranet-Admin.SharePoint.com" #Setup Credentials to connect Connect-SPOService -Url $AdminCenterURL -Credential (Get-Credential) #add guest user to sharepoint online site Add-SPOUser -Group "Marketing Visitors" –LoginName "[email protected]" -Site "https://CrescentIntranet.sharepoint.com/sites/Marketing"
SharePoint Online PowerShell to Add External User to Group
Let’s add an external user to SharePoint Online group using PnP PowerShell.
#Set Config Parameters $SiteURL = "https://crescent.sharepoint.com/sites/SalesPortal" $GroupName = "Sales Portal Members" $ExternalUserEmail = "[email protected]" #Connect to PnP Online Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential) #PowerShell to Add External User to group Add-PnPUserToGroup -Identity $GroupName -EmailAddress $ExternalUserEmail -SendEmail
If you want to invite an external user to SharePoint Online using PowerShell CSOM, use: Add External User to SharePoint Online using PowerShell