SharePoint Online: How to a Get List in PowerShell?

Requirement: SharePoint Online PowerShell to Get List.

SharePoint Online: Get List from PowerShell

Here is the PowerShell to Get SharePoint Online List

#sharepoint online get list powershell
Import-Module Microsoft.Online.SharePoint.Powershell -DisableNameChecking

#Config Variables for Site URL, List Name
$SiteURL= ""
$ListName="Sales Contacts"
#Setup Credentials to connect
$Cred = Get-Credential
Try {
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.UserName,$Cred.Password)
    #powershell sharepoint online get list
    $List = $Ctx.Web.Lists.GetByTitle($ListName)

    Write-host "Total Number of Items in the List:"$List.ItemCount
 Catch [Exception] {
      Write-host $_.Exception.Message -f Red

This script gets the given list and the number of items from the list. To get all lists in SharePoint Online site using PowerShell, use: SharePoint Online PowerShell to Get All Lists

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply