Install the modules
- Microsoft Online Service Sign-in Assistant for IT Professionals RTW
- Windows Azure Active Directory Module for Windows PowerShell (64-bit version)
- SharePoint Online Management Shell
1) Open Windows PowerShell as an administrator (use Run as administrator).
2) Run this command, and enter Office 365 Global Admin credentials.
$credential = Get-Credential
3) Run these commands to connect to Office 365.
Connect-MsolService -Credential $credential
4)Run these commands to connect to SharePoint Online. Replace your-tenant with the actual value for your domain.
Import-Module Microsoft.Online.SharePoint.PowerShell -DisableNameChecking
Connect-SPOService -Url https://your-tenant-admin.sharepoint.com -credential $credential
Get-sposite https://your-tenant.sharepoint.com/Site location
Look at Sharing Capability
what one you type to change to
“Disabled” – external user sharing (share by email) and guest link sharing are both disabled
“ExternalUserSharingOnly” – external user sharing (share by email) is enabled, but guest link sharing is disabled
“ExistingExternalUserSharingOnly” – (DEFAULT) Allow sharing only with the external users that already exist in your organization’s directory
“ExternalUserAndGuestSharing” – external user sharing (share by email) and guest link sharing are both enabled
Set-SPOSite -Identity your-tenant.sharepoint.com/Site location -SharingCapability ExternalUserSharingOnly