Forum Discussion
Setting "Anyone" share link permissions on individual sites in Sharepoint
- Dec 14, 2017
- The script updates the setting only for existing sites.
- Correct.
Ken Hardin Hello,
I was reviewing the error that you received. This is caused by not having the SharePoint Online Management Shell. If you follow this link
https://www.microsoft.com/en-us/download/details.aspx?id=35588 You can install the module which will then accept the Connect-SPOService cmdlet.
The below script is a modified variation of what is found on the previous site:
https://support.office.com/en-us/article/turn-external-sharing-on-or-off-for-sharepoint-online-6288296a-b6b7-4ea4-b4ed-c297bf833e30
- $userCredential = Get-Credential
- Connect-SPOService -Url https://TenantName-admin.sharepoint.com-admin.sharepoint.com -Credential $userCredential
- $sites = Get-SPOSite -Limit ALL -includepersonalsite:$true
- Foreach($site in $sites)
- {
- Set-SPOSite -Identity $site.Url -SharingCapability ExternalUserSharingOnly
- }
- Write-Host("External Sharing Capability updated for all sites.")
This script will need some modification from you.
- The URL section in line 2 will need to be changed to reflect the SharePoint Admin Center URL.
- The portion of line 6 "in italics" will need to be changed to reflect the sharing permission that you want to have enabled for all sites. The sharing permission can be found in the link mentioned above.
NOTE: The Script given will also update the sharing capability of all OneDrive sites as well. The script in the article does not. You can omit the OneDrive for Business from being updated by the script by changing the term in line 3 "-includepersonalsite:$true" from $true to $false.