Skip to content

Instantly share code, notes, and snippets.

@westerdaled
Created August 19, 2019 12:26
Show Gist options
  • Save westerdaled/d32c8184e14f4b448cb40472d792f4c2 to your computer and use it in GitHub Desktop.
Save westerdaled/d32c8184e14f4b448cb40472d792f4c2 to your computer and use it in GitHub Desktop.
Enable External Sharing on a SharePoint Online Site
$tenant = "yourTenant"
$tenantUrl = "https://{0}.sharepoint.com/" -f $tenant
$siteTitle = "siteToShareTitle"
$siteToShareUrl = "https://{0}.sharepoint.com/sites/{1}" -f $tenant, $siteTitle
$adminSiteUrl = "https://{0}-admin.sharepoint.com/" -f $tenant
# As we want to check tenant wide settings then connect to tenant admin site
# Prompts for credentials. This is required if the account using multi-factor authentication.
Connect-SPOService -Url $adminSiteUrl
# check tenant level sharing as whatever restriction is set here cannnot be lowered on the site we want to share below
Get-SPOTenant | fl SharingCapability
# SharingCapability : ExternalUserSharingOnly
# now check the site we want to share
Get-SPOSite $siteToShareUrl | fl SharingCapability
# SharingCapability : Disabled
# set this sharing to match the level set at the tenant
set-sposite -identity $siteToShareUrl -sharingcapability ExternalUserSharingOnly
#
# Now we are able to share our site with our desired external users
#
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment