Forum Discussion
Configure team sites to sync automatically to File Explorer
Jake Turner
Are there any problems with my formatting? Now I have ran the Powershell code according to the documentation page to fix the encoding. Is it correct that I should have these { and } around the guids?
tenantId={00000000-0000-0000-0000-000000000000}&siteId={00000000-0000-0000-0000-000000000000}&webId={00000000-0000-0000-0000-000000000000}&listId={00000000-0000-0000-0000-000000000000}&webUrl=https://example.sharepoint.com&version=1
How hard is the limit of no more than 5000 files/folders in a library? Does OneDrive check and count the objects before syncing? Theres no problem syncing these libraries manually.
Anders Gidlund and Jake Turner
I had a similar issue and using the work of Dale Hayter , and others I've modified his PowerShell script to give back the same ID that you get if you click Copy id, when you use the Sync button.
Here is the script so that it is easier for others to find:
My goal with this was to have a PowerShell way of creating the registry setting for hundreds of teams, so that we could give our users a good experience of having their Organisation Team site's synced to their File Explorer quickly and easily.
# source for this script # https://www.blackforce.co.uk/2019/09/12/sharepoint-copy-library-id-missing-for-team-site-libraries-sync # and # https://www.blackforce.co.uk/2019/06/07/automatically-sync-microsoft-sharepoint-team-site-libraries-now-live#comment-4601075707 # Adapted by Dorje McKinnon to add a variable for the folder, because channels in team sites are specific to folders # This script was setup to sync the General channel folder from a departmental team site #set the following four things for each SharePoint site / library / folder you want the Registry key for to auto sync with OneDrive #example of the URL I'm synching https://MyTennant.sharepoint.com/sites/MyDepartment/Shared Documents/General $siteName = 'MyDepartment' #Sharepoint site URL $docLib = 'Documents' #Sharepoint Document Library name not address $docLibUrl = 'Shared documents' #Sharepoint library URL $docLibFolder = 'General' #>>> everything below here likely stays the same everytime you run the script # info on howto get your tennant id # https://tomtalks.blog/2015/09/how-to-get-your-office-365-tenant-id/ $tenant = 'MyTennant' # the first part of your tennant name XXXXX.sharepoint.com $tenantId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' #Tenant ID, can be retrieved from Azure AD or PowerShell under optional. # Connection This didn't work with my setup but may work for you. #Connect-PnPOnline https://$tenant.sharepoint.com/sites/$siteName -SPOManagementShell # >>>> Login using an account with access to the site. # If you do not have MDA or modern auth then do not use the -SPOManagementShell switch Connect-PnPOnline https://$tenant.sharepoint.com/sites/$siteName # Convert Tenant ID $tenantId = $tenantId -replace '-','%2D' # Convert Site ID $PnPSite = Get-PnPSite -Includes Id | select id $PnPSite = $PnPSite.Id -replace '-','%2D' $PnPSite = '%7B' + $PnPSite + '%7D' # Convert Web ID $PnPWeb = Get-PnPWeb -Includes Id | select id $PnPWeb = $PnPWeb.Id -replace '-','%2D' $PnPWeb = '%7B' + $PnPWeb + '%7D' # Convert List ID $PnPList = Get-PnPList $docLib -Includes Id | select id $PnPList = $PnPList.Id -replace '-','%2D' $PnPList = '%7B' + $PnPList + '%7D' $PnPList = $PnPList.toUpper() # end product &folderId=ecc664be%2D3ca0%2D4a7b%2D8ec2%2Dd92be4bf4847 # Convert FolderID ID $foldertotest = '/sites/'+$siteName+'/'+$docLibUrl+'/'+$docLibFolder $PnPFolder = Get-PnPFolder -url $foldertotest -Includes UniqueId $PnPFolder = $PnPFolder.UniqueId -replace '-','%2D' $PnPFolder = '%7B' + $PnPList + '%7D' $PnPFolder = $PnPFolder.toUpper() # Enumerate the Full URL $FULLURL = 'tenantId=' + $tenantId + '&siteId=' + $PnPSite + '&webId=' + $PnPWeb + '&listId=' + $PnPList + '&folderId=' + $PnPFolder + '&webUrl=https%3A%2F%2F' + $tenant + '%2Esharepoint%2Ecom%2Fsites%2F' + $siteName + '&version=1' # Output the FULL URL To Copy and Paste Write-Output 'List ID: ' $FULLURL
- BinaryStarsFeb 24, 2023Copper Contributor
I have changed your script a bit to take into account the new powershell - love it when Microsoft change stuff 🙂
# source for this script # https://www.blackforce.co.uk/2019/09/12/sharepoint-copy-library-id-missing-for-team-site-libraries-sync # and # https://www.blackforce.co.uk/2019/06/07/automatically-sync-microsoft-sharepoint-team-site-libraries-now-live#comment-4601075707 # Adapted by Dorje McKinnon to add a variable for the folder, because channels in team sites are specific to folders # Adapted further by Ian Watson to take into account M$ changing the powershell modules # This script was setup to sync the General channel folder from a departmental team site #set the following four things for each SharePoint site / library / folder you want the Registry key for to auto sync with OneDrive #example of the URL I'm synching https://MyTennant.sharepoint.com/sites/MyDepartment/Shared Documents/General $siteName = 'MyDepartment' #Sharepoint site URL $docLib = 'Documents' #Sharepoint Document Library name not address $docLibUrl = 'Shared documents' #Sharepoint library URL $docLibFolder = 'General' #>>> Clean up old Modules and install the required modules for powershell - click yes to all when prompted Uninstall-Module -Name SharePointPnPPowerShellOnline -AllVersions -Force Install-Module -Name PnP.PowerShell #>>> everything below here likely stays the same everytime you run the script # info on howto get your tennant id # https://tomtalks.blog/2015/09/how-to-get-your-office-365-tenant-id/ $tenant = 'MyTennant' # the first part of your tennant name XXXXX.sharepoint.com $tenantId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' #Tenant ID, can be retrieved from Azure AD or PowerShell under optional. # >>>> Login using an account with access to the site. # If you do not have MDA or modern auth then do not use the -SPOManagementShell switch # You will need to accept the permissions after login if not done already Connect-PnPOnline https://$tenant.sharepoint.com/sites/$siteName -Interactive # Convert Tenant ID $tenantId = $tenantId -replace '-','%2D' # Convert Site ID $PnPSite = Get-PnPSite -Includes Id | select id $PnPSite = $PnPSite.Id -replace '-','%2D' $PnPSite = '%7B' + $PnPSite + '%7D' # Convert Web ID $PnPWeb = Get-PnPWeb -Includes Id | select id $PnPWeb = $PnPWeb.Id -replace '-','%2D' $PnPWeb = '%7B' + $PnPWeb + '%7D' # Convert List ID $PnPList = Get-PnPList $docLib -Includes Id | select id $PnPList = $PnPList.Id -replace '-','%2D' $PnPList = '%7B' + $PnPList + '%7D' $PnPList = $PnPList.toUpper() # end product &folderId=ecc664be%2D3ca0%2D4a7b%2D8ec2%2Dd92be4bf4847 # Convert FolderID ID $foldertotest = '/sites/'+$siteName+'/'+$docLibUrl+'/'+$docLibFolder $PnPFolder = Get-PnPFolder -url $foldertotest -Includes UniqueId $PnPFolder = $PnPFolder.UniqueId -replace '-','%2D' $PnPFolder = '%7B' + $PnPList + '%7D' $PnPFolder = $PnPFolder.toUpper() # Enumerate the Full URL $FULLURL = 'tenantId=' + $tenantId + '&siteId=' + $PnPSite + '&webId=' + $PnPWeb + '&listId=' + $PnPList + '&folderId=' + $PnPFolder + '&webUrl=https%3A%2F%2F' + $tenant + '%2Esharepoint%2Ecom%2Fsites%2F' + $siteName + '&version=1' # Output the FULL URL To Copy and Paste Write-Output 'List ID: ' [uri]::UnescapeDataString("$FULLURL")- Dorje-McKinnonApr 02, 2023Iron Contributor
BinaryStars many thanks for sharing your update 🙂