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!

sharepoint online enable grant permission to everyone everyone except external users groups

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.

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

One thought on “SharePoint Online: Grant Access to ‘Everyone’, ‘Everyone Except External Users’ using PowerShell

  • Is there a way to check using powershell if groups “Everyone” and “Everyone except external users” have been provided access to a SharePoint online site. And to check if the access is provided directly or via some SharePoint group.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *