Jan 28 2017 12:13 PM
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 library settings, but such approach is impractical for hundreds of Groups.
Can someone point me to an existing script for doing it for all Groups in a tenant?
TIA.
Jan 28 2017 12:58 PM
I am sorry, but I do not know of any way to disable the ability for users to synchronize a document library via PowerShell...
Jan 28 2017 01:41 PM
Jan 28 2017 02:14 PM
Jan 28 2017 02:14 PM
Jan 28 2017 02:16 PM
Jan 28 2017 04:30 PM
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() } } } }
Jan 29 2017 02:15 AM
Thank you very much @jcgonzalezmartin @Brent Ellis !!!
I have a couple of questions:
TIA
Jan 29 2017 03:19 AM - edited Jan 29 2017 05:22 AM
Testing the script, I noticed that it sets "ExcludeFromOfflineClient=$true" not only on the main doclib of the Group, but also on other libraries (in Italian, the typical libraries affected are: Documenti, Modelli di modulo, Raccolta stili, Risorse del sito).
Does this have adverse consequences?
How to restrict the script only to actual doclibs?
Jan 29 2017 05:26 AM
Jan 29 2017 06:24 AM
Thanks Brent.
The best would be to disable sync for all actual doclibs (i.e. the main one and any other doclibs created by the users) but not for other "system" libraries.
Unfortunately it looks like the condition $Library.BaseTemplate -eq "101" captures other "system" libraries as well (precisely, in Italian: Modelli di modulo, Raccolta stili, Risorse del sito).
I wonder if flipping ExcludeFromOfflineClient also for such "system" libraries (which appear to have $Library.BaseTemplate -eq "101") could have adverse side effects ?
Jan 29 2017 08:55 AM
Jan 29 2017 09:15 AM
Thanks Juan!
And, after disabling, what happens to the local syncs already configured in the various machines?
Will they be automagically disabled (and in this case what will happen to the local file copies?) or will they continue to work?
In other words, does the setting purely hide the sync button in the web UI, or does it influence the behaviour of the OneDrive clients on the various machines?
Jan 29 2017 09:21 AM
Jan 30 2017 02:04 AM
Forgive this non-SPO person asking a question, but I would like to summarize what has been discussed here.
Did I get that right?
Jan 30 2017 03:03 AM
My two cents:
Jan 30 2017 03:41 AM
Library.BaseTemplate = 101 specifies document libraries belonging to Office 365 Groups... Or all modern sites?
In the past, Groups used a special Group#0 template for its sites. Is that the same now (in an airplane with limited wi-fi so don't want to go through the slowwwwwww network check...) Maybe someone knows offhand.
Jan 30 2017 03:55 AM
Jan 30 2017 04:05 AM
Ta. Like everywhere in Office 365, if you take your eyes off the ball for a few minutes, things might change...
Good to know about the identifiers for document libraries. I like factoids like that!