Get SharePoint items from lists by using PowerShell

This post describes how to get SharePoint items from any lists by using PowerShell.

In some BI architectures, where the user wants to store the data in spreadsheets or somewhere that is not stored within a database, we can usually offer the option of storing that data within a list in SharePoint.

In this way, we can create lists and store data, creating a more complete organization, security, access via MS Office 365, history of data changes, etc.

Again, I’m not a PowerShell expert, but after looking at forums, official documentation and even talking to Microsoft support, I managed to solve the problem we had with the solutions below.

So, before showing the PowerShell script, it is necessary that the user who will access the service must be an admin user in order to have access to the data without restriction.

To run the PowerShell script it will also be necessary to install the Sharepoint module available at the link below, if the module is not installed, it will not be possible to run the script successfully. Preferably install the module “SharePointPnPPowerShellOnline”, which is the module for SharePoint Cmdlets, but it’s necessary to install the modules for each problem.

After installing the module successfully, you should save the script below and run it in PowerShell.

The first script, obtains the data using the module “Get-PnPListItem”, and its function is to retrieve items from lists, all documentation can be found in the link below as well.

If your script is showing the error below, you must add the “PnP Management Shell” in the business applications on the Azure portal.

The user or administrator has not consented to use the application with ID "00000000-0000-0000-0000-000000000000"(the id code is just an example). Send an interactive authorization request for this user and resource.

If you want to add via hyperlink, the documentation is below too.

Or just replace with your Azure AD tenant name, which typically is

Thas it! We can now obtain data from Sharepoint lists, through PowerShell using Cmdlets commands.

The script for this post can be found on my github.

Mechanical Engineer Business Intelligence developer, passionate about technology, I have knowledge and experience to create a BI architecture and much more 📚.