Get All Items from a Sharepoint Online List or Library
Description: This PnP Powershell script will list all the item paths of a sharepoint onlone list or library to a csv file
This takes site collection url and list name as input and generate a csv file with the item url's
This takes into consideration large lists and retrieve items in batches avoiding threshold errors.
Connect-PnPOnline -Url https://mytenant.sharepoint.com/sites/sitecoll
$outfile = "C:\Users\listitems.csv"
$listname = "listname"
$libitems = Get-PnPListItem -List $listname -Fields "FileLeafRef" -PageSize 2000
foreach($item in $libitems)
{
$item["FileRef"] | Add-Content $outfile
}