SharePoint Online: Grant Access to ‘Everyone’, ‘Everyone Except External Users’ using PowerShell
Requirement: Grant Access to “Everyone” and “Everyone Except External Users” groups in SharePoint Online.
How to Grant Access to Everyone or Everyone Except External Users Groups?
Prerequisites: Make sure You have Enabled “Everyone” and “Everyone Except External Users” claims in SharePoint Online before running these PowerShell scripts.
Granting access rights to either the “Everyone” or “Everyone except the external users” group is no different from adding any other users to SharePoint Online sites. Just navigate to the site, click on site permissions, select the relevant group, pick these groups from the people picker, and then click on “Share” – You are done!
You can also share the site with everyone group by directly adding them to the site with the proper permission level.
PowerShell to Grant Permissions to Everyone or Everyone Except External Users Group
Permissions in SharePoint Online can be granted to individual users or groups through PowerShell. It is also possible to grant permissions to Everyone or Everyone except external users.
Grant access to “Everyone” in SharePoint Online using PowerShell
Let’s share the site with the “Everyone” group by adding them to the visitors group of the site using PowerShell.
#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#"Everyone" Group's Login ID
$LoginName = "c:0(.s|true"
#Get the Members Group of the site
$VisitorsGroup = Get-PnPGroup -AssociatedVisitorGroup
#Add Everyone Except External users claim to Site Group
Add-PnPGroupMember -LoginName $LoginName -Identity $VisitorsGroup
This grants access to all authenticated users to the SharePoint Online site.
PowerShell to Add “Everyone except external users” to SharePoint Online
Similarly, to grant permissions to “Everyone except external users” in SharePoint Online – Here is the PowerShell script.
#Parameters
$SiteURL = "https://Crescent.sharepoint.com/sites/marketing"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
#Get "Everyone Except External Users" Login ID
$LoginName = "c:0-.f|rolemanager|spo-grid-all-users/$(Get-PnPTenantID)"
#Get the Members Group of the site
$MembersGroup = Get-PnPGroup -AssociatedMemberGroup
#Add Everyone Except External users claim to Site Group
Add-PnPGroupMember -LoginName $LoginName -Identity $MembersGroup
The Syntax for the “Everyone Except External Users” claim is tricky here.