How to Get a List by GUID in SharePoint Online?
Requirement: Get a List from GUID in SharePoint Online.
Get List by GUID in SharePoint Online using PowerShell:
Have you ever needed to get a list by its GUID in SharePoint Online? Perhaps you’ve got the GUID of the list and wanted to identify the list, or you need to do something with the data from a particular list. In any case, it’s easy to find the list from its GUID either with the web browser or with the help of PowerShell. In this post, I’ll show you how to get a list by GUID in SharePoint Online.
To get a list from its GUID, you can use this URL: https://crescent.sharepoint.com/_layouts/15/listedit.aspx?List=GUID,
This takes you to the list settings page of the given GUID. Let’s use PowerShell CSOM to get a list from GUID:
PowerShell to Get List from GUID
Here is how to get a SharePoint Online list by its GUID using Client-side object model and PowerShell:
#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
#Config Parameters
$SiteURL="https://crescent.sharepoint.com"
$ListGUID = [System.Guid]("9a939664-ace4-44af-ad6e-26cefd2e8d32")
#Get Credentials to connect
$Cred= Get-Credential
#Setup the context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
#Get List by id
$List=$Ctx.Web.Lists.GetById($ListGUID)
$Ctx.load($List)
$Ctx.ExecuteQuery()
Write-host "Total Number of List Items:"$List.ItemCount
PnP PowerShell to Get List by GUID in SharePoint Online
We can also use the PnP PowerShell to fetch the list from its GUID.
#Config Parameters
$SiteURL="https://crescent.sharepoint.com"
$ListGUID = [System.Guid]("c94f7b39-2e07-4e40-90b7-c613630e5f8d")
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)
#Get list by GUID
$List = Get-PnPList -Identity $ListGUID
#Get List Name
Write-host "List Name:" $List.Title
If you want to get a list GUID in SharePoint Online: How to Get List GUID in SharePoint Online?