PnP – Get list Item count in excel using PowerShell

Get List Item count from specific site with the metadata.

$cred = Get-Credential
Connect-PnPOnline -Url https://<TenentName>.sharepoint.com/sites/developer/ -Credentials $cred

$ListItemCollection = @();
$Lists = Get-PnPList
foreach($list in $Lists){

    $row = New-Object psobject
    Add-Member -InputObject $row -MemberType NoteProperty -Name "ListName" -Value $list.Title
    Add-Member -InputObject $row -MemberType NoteProperty -Name "ListURL" -Value $list.RootFolder.ServerRelativeUrl
    Add-Member -InputObject $row -MemberType NoteProperty -Name "ItemCount" -Value $list.ItemCount
    Add-Member -InputObject $row -MemberType NoteProperty -Name "LastModifyOn" -Value $list.LastItemModifiedDate

    $ListItemCollection += $row;
}

$ListItemCollection | Export-CSV "D:\ListData.csv" -NoTypeInformation

Sharing is Caring 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.