SharePoint online has feature called External Sharing to share your content with external vendors, clients or external customers in collaborative environment. Refer this article to know more about external sharing : Manage external sharing for your SharePoint Online environment
We can use the SharePoint online powershell cmdlet Set-SPOSite to enable or disable external sharing at site collection level by using the parameter –SharingCapability.
Enable external sharing for site collection
The following command enable external sharing for the given site collection. It allows only external users who have to sign in as authenticated users.
$siteCollectionURL = "https://mytenant.sharepoint.com/sites/contoso" Set-SPOSite -Identity $siteCollectionURL -SharingCapability ExternalUserSharingOnly
The following command enable external sharing to allow for both authenticated users and anonymous guest links.
$siteCollectionURL = "https://mytenant.sharepoint.com/sites/contoso" Set-SPOSite -Identity $siteCollectionURL -SharingCapability ExternalUserAndGuestSharing
Disable external sharing for a site collection
The following command disable external sharing for the given site collection.
$siteCollectionURL = "https://mytenant.sharepoint.com/sites/contoso" Set-SPOSite -Identity $siteCollectionURL -SharingCapability Disabled
Check external sharing status for a site collection
The following powershell command check the status of external sharing for the given site collection.
$siteCollectionURL = "https://mytenant.sharepoint.com/sites/contoso" $site = Get-SPOSite -Identity $siteCollectionURL if($site.SharingCapability -eq "Disabled") { Write-Host "External sharing is disabled for"$site.URL -ForegroundColor Green } else { Write-Host "External sharing is enabled" -ForegroundColor Yellow }
Advertisement