Get All Items in a Document Library (PnP PowerShell)
Get All Items in a Document Library (PnP PowerShell)
Issue
The Code
# Variables
$Domain = "<tenant-name>"
$SiteName = "<site-name>"
$ListName = "<list-name>"
$SiteURL = "https://$Domain.sharepoint.com/sites/$SiteName"
#Connect to Site
Connect-PnPOnline -Url $SiteURL -Interactive
#Get the List
$List = Get-PnPList -Identity $ListName
#Get all Folders from List - with progress bar
$global:counter = 0;
$Items = Get-PnPListItem -List $List -PageSize 5000 `
-Fields FileLeafRef `
-ScriptBlock {
Param($items) $global:counter += $items.Count
Write-Progress -PercentComplete ($global:Counter / ($List.ItemCount) * 100) -Activity "Getting Folders from List:" -Status "Processing Items $global:Counter to $($List.ItemCount)";
}Credits
Last updated