How to get list name using its guid in CSOM powershell

I tried:


But this is not working. Please suggest.


Convert string to guide before passing it getlistbyid

$guid = [GUID] ("guidnumber")

You need to make sure there are not special chars in GUID.

An example for you:

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"  

$siteURL = "https://xxx.sharepoint.com/sites/xx"  
$userId = "xxx@xxx.onmicrosoft.com"  
$pwd = Read-Host -Prompt "Enter password" -AsSecureString  
$creds = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($userId, $pwd)  
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($siteURL)  
$ctx.credentials = $creds  
    $lists = $ctx.web.Lists  
    #$list = $lists.GetByTitle("list666")  
    $guid = [GUID] ("8A3AE548-0F20-4705-A047-5CF855543704")
    $list = $lists.GetById($guid)


    write-host "$($_.Exception.Message)" -foregroundcolor red  

enter image description here


This code works in Powershell:

Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$spWeb = Get-SPWeb "https://your.sharepoint.url/any-site/"

# If the GUID is a string, set a GUID Powershell object:
$spListGUID = [GUID]"{ABCD1234-AB12-AB12-AB12-ABCDEF123456}"

#Get the list via its GUID:
$spList = $spWeb.Lists[$spListGUID]

Write-Host "List Title: " $spList.Title

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.