In this blog post, I will show you how to enable external Sharing of folders a content on SharePoint Online.
By default, Office 365 doesn’t allow external Sharing of data with people that are not part of the organization and have an external email address.
If you try to share documents with an external user you will receive the error message below.
Error Message
Your organization’s policies don’t allow you to share with these users. Go to External Sharing in the Office 365 admin centre to enable it.

Allow External Sharing
To allow External Sharing you will need to run the PowerShell cmdlet that will allow external sharing as I will show you below.
Connect To SharePoint Online Script
Before you can run the cmdlet you will need to connect to SharePoint Online using the code below.
Copy it to a text file and save it as. PS1 file.
Change the values in the AdminUPN to your username (You need to be a Global Administrator)
Type your Tenant name is the OrgName.
$adminUPN=""
$orgName="Yourtanentname"
$userCredential = Get-Credential -UserName $adminUPN -Message "Type the password."
Connect-SPOService -Url https://$orgName-admin.sharepoint.com -Credential $userCredential
Change External Sharing Policy
To set the external Sharing policy, replace the ididentityRL with the your site URL (the site you would like to allow external sharing) and run the command.
set-sposite -identity https://tanentname.sharepoint.com/sites/sitename -sharingcapability ExternalUserAndGuestSharing
