Request a 60-minute free consultation

Get all List Items from a SharePoint Online List

To retrieve all items from a SharePoint list using PowerShell, you can use the SharePoint Online Management Shell module. Here's a PowerShell script to accomplish this task:


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

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

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

# Get all items from the SharePoint list
$items = Get-PnPTenantSite | ForEach-Object { Get-PnPTenantSiteTemplate $_.TemplateId } | Where-Object { $_.Type -eq "List" -and $_.Title -eq $listName } | Get-PnPTenantList

# Loop through and display each item
foreach ($item in $items) {
    $list = Get-PnPTenantList -Identity $item.TemplateId
    Write-Host "Items in $listName:"
    Get-PnPTenantListItem -List $list | ForEach-Object {
        Write-Host "Item Title: $($_['Title'])"
        Write-Host "Item ID: $($_.Id)"
        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 containing the list.
  • "YourListName": Replace with the name of the SharePoint list from which you want to retrieve items.

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, retrieve all items from the specified list, and display their titles and IDs.

Ensure you have the necessary permissions to access the site and retrieve list item information.

Other solutions

Connect with HarjGroup

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