Request a 60-minute free consultation

Get all Lists in a SharePoint Online Site

To retrieve all lists in a SharePoint Online (SPO) site. Here's a PowerShell script to accomplish this task:


# Define the SharePoint Online site URL
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSiteName" # Replace with your site's URL

# Connect to SharePoint Online
Connect-SPOService -url "https://yourtenant-admin.sharepoint.com"

# Connect to the SharePoint site
Connect-PnPOnline -Url $siteUrl -UseWebLogin

# Get all lists in the SharePoint site
$lists = Get-PnPTenantSite | ForEach-Object { Get-PnPTenantSiteTemplate $_.TemplateId } | Where-Object { $_.Type -eq "List" }

# Display the list names
foreach ($list in $lists) {
    Write-Host "List Title: $($list.Title)"
    Write-Host "List URL: $($list.ServerRelativeUrl)"
    Write-Host "------------------------"
}

# Disconnect from SharePoint Online
Disconnect-PnPOnline

# Disconnect from SharePoint Online Management Shell
Disconnect-SPOService


Instructions:

Replace the following placeholders in the script with your specific information:

  • https://yourtenant.sharepoint.com/sites/YourSiteName: Replace with the URL of the SharePoint site from which you want to retrieve lists.

After updating the script with your information, save it as a .ps1 file and run it using PowerShell. This script will connect to your SharePoint Online site and retrieve a list of all lists within that site, displaying their titles and URLs.

Make sure you have the necessary permissions to access the site and retrieve list information.

Other solutions

Connect with HarjGroup

Contact Us
Find out how HarjGroup's expertise can help you and your company.