Link to home
Start Free TrialLog in
Avatar of Robcarter10
Robcarter10Flag for United States of America

asked on

How to get library id from sharepoint site in order to sync using Intune

I am trying to automatically sync a few sharepoint document libraries using the Administrative Templates in Microsoft Intune. All of the instructions that I have found have said to go to the document library, click sync and the click the option to copy the library id. However, that option does not appear for me even though I am a global admin. I contacted Microsoft support and they could not tell me why I did not have that option. I was told how to find the library id but I think there is more than that which is copied from it based on what I have read. I would appreciate if someone could either tell me how to get the option to copy the library id to appear or how I can retrieve the information another way. I already tried just placing the library id in the administrative template but that did not work.
ASKER CERTIFIED SOLUTION
Avatar of Zvonko
Zvonko
Flag of North Macedonia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Robcarter10

ASKER

I used the powershell script in the first link and did get the info to put into Intune. I just have to see if it works. The policy did sync with my devices but it is not working yet. The posts that you listed say that it can take up to 8 hours. So, I will have to wait and see.
Zvonko זְאֵב- The first link that you included solved my problem. I searched for days and never found that post. Thanks for your help!
You are welcome  :  )
Only to complete this I have copied the PowerShell source from here:
https://gist.githubusercontent.com/win2000b/5ad0c973a36ecc5458dcdd6a469a142c/raw/a4db147f439f028cc03f72120f82434bd24f1f08/GetLibraryID.ps1
# Optional, To get your tenant ID via PowerShell
Connect-msolservice
Get-MSOLCompanyInformation | select objectID

# Install SharePoint PowerShell If needed
Install-Module SharePointPnPPowerShellOnline

# Example https://$tenant.sharepoint.com/sites/$siteName
$tenant = 'Enter your Tenant Name in Here' # xxxx.onmicrosoft.com
$tenantId = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' #Tenant ID, can be retrieved from Azure AD or PowerShell under optional.
$siteName = 'sales' #Sharepoint site name
$docLib = 'Enquiries' #Sharepoint Document Library

# Connection
Connect-PnPOnline https://$tenant.sharepoint.com/sites/$siteName -SPOManagementShell

# 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()

# Enumerate the Full URL
$FULLURL = 'tenantId=' + $tenantId + '&siteId=' + $PnPSite + '&webId=' + $PnPWeb + '&listId=' + $PnPList + '&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

Open in new window