01-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.
cc @Juan Carlos González Martín @Santhosh Balakrishnan @Tony Redmond
01-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...
01-28-2017 01:41 PM
01-28-2017 02:14 PM
01-28-2017 02:14 PM
01-28-2017 02:16 PM
01-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() } } } }
01-29-2017 02:15 AM
Thank you very much @Juan Carlos González Martín @Brent Ellis !!!
I have a couple of questions:
TIA
01-29-2017 03:19 AM - edited 01-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?
01-29-2017 05:26 AM
01-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 ?
01-29-2017 08:55 AM
01-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?
01-29-2017 09:21 AM
01-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?
01-30-2017 03:03 AM
My two cents:
01-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.
01-30-2017 03:55 AM
01-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!
01-30-2017 04:38 AM
Nevertheless, my question still remains unanswered...
I will try to be more clear.
We know the following facts:
All this said, if we want to hide the sync button in all "user" libraries by means of a script, and we select the libraries on the basis of template ID 101, we will (try to) hide the sync button also in the "system" document libraries (point 2) and not only in the "user" document libraries (point 1 and point 3).
My question is: is this safe?
(Of course in the script I can select the "user" document libraries "by name", but while this is easily feasible for the "main" one (point 1 above), it is instead difficult for the others (point 3 above))...
01-30-2017 04:49 AM
I guess I need more context. I do not think that the "system" document libraries are used by Office 365 Groups - unless someone can shed more light on this topic. If that is the case, then it might not be important if synchronization was disabled for these libraries. Do users ever synchronize them anyway?
01-30-2017 05:00 AM
My feeling is that it is not important if synchronization is disabled for these "system" libraries (and anyway users never synchronize them, I think), but I would like to have an "authoritative" answer...
01-30-2017 05:03 AM
I can't think of why a user would want or attempt to synchronize these libraries...
01-30-2017 05:22 AM
01-30-2017 05:41 AM
Should that comment be "users sometimes do silly things"?
Never mind...
02-05-2017 03:31 AM
Hi Juan,
I have read the posts here a few times, but are still not sure that this will solve what i am trying to do.
I am basicly looking for a scriptet solution that does the same as opening site settings for a single SPO site or O365 group, going into "Search and offline availability" and select no to "Specify whether this site should be available for offline clients".
Can i use your Csom script for this ?
02-05-2017 05:23 AM
02-06-2017 08:59 AM - edited 02-06-2017 11:00 AM
I took a stab at this using the scripts already created by @Juan Carlos González Martín and @Brent Ellis along with the site iteration scripts here. This will set the Offline Client Availability at the web level initially for the site you enter and give you the option to do all subsites (I edited the original to include all levels of subsites based on this super handy script here and not just level 1). I tested this on Group and Classic sites. It certainly could be cleaned up a bit and be enhanced to support things like .csv input and probably overall more optimized.
Add-Type -Path "C:\temp\microsoft.sharepointonline.csom.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.dll" Add-Type -Path "C:\temp\microsoft.sharepointonline.csom.16.1.6008.1200\lib\net45\Microsoft.SharePoint.Client.runtime.dll" $siteUrl = Read-Host -Prompt "Enter Site Collection URL" $username = Read-Host -Prompt “Enter username” $password = Read-Host -Prompt “Enter password” -AsSecureString $subwebcheck = Read-Host -Prompt "Do you want to process subsites? (Y/N)" # Generate ClientContext function so we can reuse function GetClientContext($siteurl, $username, $password) { $ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteurl) $credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $password) $ctx.Credentials = $credentials return $ctx } $ctx = GetClientContext $siteurl $username $password if ($ctx.ServerObjectIsNull.Value) { Write-Host "Unable to connect to: '$siteUrl'" -ForegroundColor Red } else { Write-Host "Connected to: '$($siteUrl)'" -ForegroundColor Green $rootWeb = $ctx.Web $ctx.Load($rootWeb) $ctx.ExecuteQuery() # update root site Write-Host $rootWeb.Url "is being updated to exclude from offline clients" $rootWeb.ExcludeFromOfflineClient=$true $rootWeb.Update() $ctx.Load($rootWeb) $ctx.ExecuteQuery() Write-Host "ExcludeFromOfflineClient is now" $rootWeb.ExcludeFromOfflineClient "for the site:" $rootWeb.Url -ForegroundColor Green if ($subwebcheck -eq "Y") { # work with subsites Write-Host "Processing subsites..." -ForegroundColor Yellow $childWebs = $rootWeb.Webs $ctx.Load($childWebs) $ctx.ExecuteQuery() foreach ($childWeb in $childWebs) { processsubsites $childWeb.url } } # function to loop through subsites and setting values function processsubsites ($siteurl){ $ctx = GetClientContext $siteurl $username $password $rootWeb = $ctx.Web $childWebs = $rootWeb.Webs $ctx.Load($rootWeb) $ctx.Load($childWebs) $ctx.ExecuteQuery() # perform update if($rootWeb.WebTemplate -ne "APP"){ Write-Host $rootWeb.Url "is being updated to exclude from offline clients" $rootWeb.ExcludeFromOfflineClient=$true $rootWeb.Update() $ctx.Load($rootWeb) $ctx.ExecuteQuery() Write-Host "ExcludeFromOfflineClient is now" $rootWeb.ExcludeFromOfflineClient "for the site:" $rootWeb.Url -ForegroundColor Green } # loop subsites of subsites foreach ($childWeb in $childWebs) { processsubsites $childWeb.url } } }
To note, Setting this property to true does not disable synchronization. Instead, it represents a recommendation to the client not to attempt synchronization. This info is pulled from here.
02-06-2017 11:48 PM
Thankyou so much Drew. This was spot on what i was looking for. Saved my day. Again, thanks a lot.
11-17-2017 05:01 AM
this script works very well for existing groups. But is it also possible to disable syncronization when creating a group? Otherwise you always have to switch something off afterwards