Forum Discussion
Turning off sharing with externals on all sharepoint sites, teams and groups?
- Jun 22, 2020
Odenkaz I think so by what is described here: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-customizations-provisioning-sites#provisioning-modern-team-sites
But, after reading your original post I think the problem is the default limit(200) for the output, please add the "-limit All" to the get-SPOSite cmdlet.
$AllSitesURLs = $(Get-SPOSite -Limit All | where{$_.status -eq 'Active' -and $_.Template -notlike "SPSMSITEHOST*" -and $_.Template -notlike "POINTPUBLISHINGHUB*"}).URL #You can play with the filter to set only those sites that you require $Count = $AllSitesURLs.count Write-Host 'Total Sites Gathered' $Count -Foreground Cyan Foreach($SiteURL in $AllSitesURLs) { Set-SPOSite -Identity $SiteURL -SharingCapability Disabled #Here you can set the sharing options that you consider better.https://docs.microsoft.com/en-us/sharepoint/turn-external-sharing-on-or-off } $STS3Sites = Get-SPOSite -Limit All -Template 'STS#3' #filter by template, it is easier with the template switch $AllTemplates = Get-SPOSite -Limit All | select Template -Unique # just to know what are the templates that you are using on your tenant. 😃
Hi Erick,
Thanks for the help!
I have a doubt. Did you use the Template IDs? If so, what is the ID for modern team sites?
I'm trying to play around with the snippet you shared and it's not disabling sharing for team sites.
is the code for modern team site: STS#3?
Odenkaz I think so by what is described here: https://docs.microsoft.com/en-us/sharepoint/dev/solution-guidance/modern-experience-customizations-provisioning-sites#provisioning-modern-team-sites
But, after reading your original post I think the problem is the default limit(200) for the output, please add the "-limit All" to the get-SPOSite cmdlet.
$AllSitesURLs = $(Get-SPOSite -Limit All | where{$_.status -eq 'Active' -and $_.Template -notlike "SPSMSITEHOST*" -and $_.Template -notlike "POINTPUBLISHINGHUB*"}).URL #You can play with the filter to set only those sites that you require
$Count = $AllSitesURLs.count
Write-Host 'Total Sites Gathered' $Count -Foreground Cyan
Foreach($SiteURL in $AllSitesURLs)
{
Set-SPOSite -Identity $SiteURL -SharingCapability Disabled #Here you can set the sharing options that you consider better.https://docs.microsoft.com/en-us/sharepoint/turn-external-sharing-on-or-off
}
$STS3Sites = Get-SPOSite -Limit All -Template 'STS#3' #filter by template, it is easier with the template switch
$AllTemplates = Get-SPOSite -Limit All | select Template -Unique # just to know what are the templates that you are using on your tenant. 😃