I setup new Sharepoint list, customized the form using Power App and able to view it and add new data. Now trying to setup a connection to this list to extract items that were added and unable to see the list. Tried using Visual Basic code - libraries - Microsoft.SharePoint.Client.dll, Microsoft.SharePoint.Client.Runtime.dll - got error 'The remote server returned an error: (400) Bad request'. Please note that I used similar script to connect to a different Sharepoint list (different organization though) and it worked just fine. That tells me that some settings might be blocking me from accessing the list? The user account I'm using to connect - has Sharepoint owner full rights - so should be able to connect and see all lists. Tried to connect using Powershell code, using actual GUID for the list - got error: Exception calling "ExecuteQuery" with "0" argument(s): "List does not exist. The page you selected contains a list that does not exist. It may have been deleted by another user." List does exist and I can easily pull it up by URL.

The Powershell code:

#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
$ListGUID = [System.Guid]("38xxxxxx-xxxx-xxxx-xxxx-aef6bcxxxxx")

#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

Write-host "Total Number of List Items:"$List.ItemCount


  • How did you get ListGUID because error says that it's not correct Commented Feb 13, 2023 at 13:20
  • I found it by opening SP list - list settings and then check the url. Url will have the list guid as a param List=%7B247c5fd8-32cd-4536-b1d0-e2e62845f174%7D %7B and %7D are the parenthesis around the guid. As I've mentioned above, I tried to get to it by name, using visual basic - got error as well. Seems something isn't right in Sharepoint itself
    – Alla
    Commented Feb 13, 2023 at 18:34
  • try $ListGUID.Guid : ( $List=$Ctx.Web.Lists.GetById($ListGUID.Guid) ) Commented Mar 5, 2023 at 14:25

1 Answer 1


I resolved the issue, by loading web first, and pulling list by name instead. Added code:

$web = $Ctx.Web;
$list = $Ctx.Web.Lists.GetByTitle("ListName")

Thank you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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