Forum Discussion
Salvatore Biscari
Jan 28, 2017Silver Contributor
Script to mass disable sync for Office 365 Groups
A customer of mine wants to disable sync for all Groups doclibs. AFAIK there is not a global setting for this. I know that it is possible to do it manually for every single doclib in the advanced l...
Jan 28, 2017
Brent, check my script...It works and I used December edition of the CSOM (https://jcgonzalezmartin.wordpress.com/2017/01/19/office-365-how-to-disable-files-synchronization-in-spo-doc-libraries-ii/)
Brent Ellis
Jan 28, 2017Silver Contributor
Looks like it was still reading from my older version of CSOM, but got it working quick and dirty:
Add-Type -Path "C:\SP\Microsoft.SharePointOnline.CSOM.16.1.6112.1200\lib\net45\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\SP\Microsoft.SharePointOnline.CSOM.16.1.6112.1200\lib\net45\Microsoft.SharePoint.Client.runtime.dll"
# SharePoint Authentication
$username = "<username here>"
$password = '<password here>'
$securePassword = ConvertTo-SecureString $Password -AsPlainText -Force
$credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePassword)
Write-Host "Fetching O365 Groups" -ForegroundColor Yellow
$o365Groups = get-unifiedgroup
$count = 0
foreach($group in $o365Groups){
$count++
Write-Host ""
Write-Host $count $group.DisplayName $group.primarysmtpaddress -ForegroundColor Cyan
$clientContext = New-Object Microsoft.SharePoint.Client.ClientContext($group.SharePointSiteUrl)
$clientContext.Credentials = $credentials
if ($clientContext.ServerObjectIsNull.Value) {
Write-Host "Unable to connect to: '$url'" -ForegroundColor Red
} else {
Write-Host "Connected to: '$($group.SharePointSiteUrl)'" -ForegroundColor Green
$Libraries = $clientContext.Web.Lists
$clientContext.Load($Libraries)
$clientContext.ExecuteQuery()
foreach($Library in $Libraries){
if($Library.BaseTemplate -eq "101"){
Write-Host $Library.Title
$Library.ExcludeFromOfflineClient=$true
$Library.Update()
}
}
}
}