Getting Started with Modern PnP PowerShell for SharePoint Online
- Milan Gross
- Apr 15
- 5 min read
Updated: May 4
After frequently being asked about how to correctly setup PowerShell to use with SharePoint Online I decided to consolidate the basics into a simple article for those new to PowerShell. I know this is particularly frustrating for people who don’t regularly use command line tools but just need to get one thing done and find too many conflicting instructions on the internet.
First of all, let’s sort out the confusion over different PowerShell approaches and which one we are using here. We are specifically demonstrating how to connect to SharePoint Online to work with data in lists and libraries. For that the current best-practice solution to use is PnP PowerShell (also referred to as PnP.PowerShell), an open source solution that I’ll show you how to install and use.
There is a separate command set called the SharePoint Online Management Shell (also referred to as Microsoft.Online.SharePoint.PowerShell) which is used to perform tenant operations such as creating new sites or listing out site collections. If you are trying to perform a simple query on a list or update of data in your lists or libraries you don’t need this solution. So, if you see commands that include “Connect-SPOService”, you can skip that script.
There is also a different PowerShell command set for SharePoint Server (2010, 2013, 2016, 2019, SE) known as SharePoint Management Shell which is incompatible with SharePoint Online. So, if you see examples with commands that include “Get-SPWeb”, that script will not work with SharePoint Online.
And if that isn’t confusing enough, beware, there are still articles that refer to an older, deprecated version of the PnP PowerShell referred to as “Classic PnP PowerShell” or SharePointPnPPowerShellOnline which shares most of the same cmdlets with the current PnP PowerShell. While this will still technically work, it is no longer supported. So, if you see command which include “Install-Module
SharePointPnPPowerShellOnline”, you would be better off looking for a script which uses the modern PnP PowerShell.
Tool | Target Environment | Scope | Use Case | Authentication Support | Status |
---|---|---|---|---|---|
PnP PowerShell (PnP.PowerShell) | SharePoint Online & Microsoft 365 | Site + Tenant | Content, sites, lists, Teams, Graph API | MFA, Certificate, Client Secret | Actively maintained |
SharePoint Online Management Shell | SharePoint Online | Tenant | Admin tasks (site creation, policy mgmt) | No MFA support | Limited, legacy use |
SharePoint Management Shell | SharePoint Server (On-Prem) | Farm | Administer SP on-prem farm (SP2010–SPSE) | N/A (runs on SP servers) | For on-prem only |
Classic PnP PowerShell (SharePointPnPPowerShellOnline) | SharePoint Online | Site | Older PnP cmdlets for SPO | MFA | Deprecated since 2020 |
Table 1: The flavors of PowerShell for SharePoint
In the rest of this guide I’ll walk you through the steps for installing the right tools, connecting securely using your Microsoft 365 account, and performing basic operations like reading and updating data in a SharePoint list.
Step 1: Install the PowerShell 7
Windows 10/11 come installed with Windows PowerShell (PowerShell 5.1) but PnP PowerShell requires PowerShell 7.4.4 or later (also referred to as PowerShell Core). This isn’t just an upgraded version of PowerShell but a completely separate application which is cross-platform and used for most PowerShell modules today. To install:
Run Windows PowerShell as Administrator
Install PowerShell, enter:
winget install --id Microsoft.PowerShell --source winget

This works smoothly on Windows 11. If you are installing on Windows Server or Windows 10 you may have to download and install it manually.
Step 2: Install the PnP PowerShell Module
Run PowerShell 7 as Administrator
Install PnP PowerShell, enter:
Install-Module -Name PnP.PowerShell -Force -Scope CurrentUser
3. Verify it is installed correctly, enter:
get-Module -Name PnP.PowerShell -ListAvailable | select-Object -Property Name, Version, Path

Step 3: Connect to SharePoint Online
The simplest way to connect is using interactive login with a ClientID value associated with an Entra App Registration. Creating the App Registration and identifying the ClientID is the subject of another of my posts. See my guide on Creating App Registrations for PnP PowerShell. In short, the App Registration is needed to make the connection compatible with MFA-enabled accounts.
$siteUrl = “https://[yourtenant].sharepoint.com/sites/[yoursite]”
$clientID = “app registration ID”
Connect-PnPOnline -Url $siteUrl -Interactive -ClientId $clientID
You can run the commands directly in the PowerShell console or create a txt file with any name and rename the extension to “.ps1” and then call the script in PowerShell using the syntax “.\[file name]”
Step 4: Read Data from a SharePoint List
Let's say you have a SharePoint list called Projects. Here's how to read all list items and generate a default output:
$items = Get-PnPListItem -List "Projects"
Write-Output $items

For a more structured output display we can loop through the items and add them to an ad-hoc object (PSCustomObject) where we can define the column headers and fields for the output then pipe the entire object through Format-Table to render in a neat table output.
Note that when you create columns in Modern SharePoint lists using the Add Column command at the top of a blank column, the editor conveniently removes the spaces when creating the Internal Column Name. It is the internal name that we must reference in code.
$items | ForEach-Object {
[PSCustomObject]@{
ID = $_["ID"]
Title = $_["Title"]
"Projected End Date"= $_["ProjectedEndDate"].ToString("yyyy-MM-dd")
Status = $_["Status"]
}
} | Format-Table -AutoSize

Step 5: Update Data in a SharePoint List
To update the value of a list item we can use the Set-PnPListItem cmdlet and pass in a hashtable of values (using @{}) which lets us update multiple fields at once.
Set-PnPListItem -List "Projects" -Identity 5 -Values @{
"Status" = "Completed"
"ProjectedEndDate" = Get-Date "2025-04-15"
}
Step 6: Add a New List Item
To create a new item in the list we use the Add-PnPListItem cmdlet and pass the values
Add-PnPListItem -List "Projects" -Values @{
"Title" = "New Website Launch"
"Status" = "Planned"
"StartDate" = Get-Date
"ProjectedEndDate" = Get-Date "2025-08-10"
}
Step 7: Disconnect the session
While it is not strictly necessary, closing the session connection is a best practice as it releases the authentication token and cleans up any memory in use.
Disconnect-PnPOnline
Conclusion
Working with SharePoint Online using PnP PowerShell gives you powerful scripting capabilities to query and manage lists, libraries, and site content more efficiently.
Points to remember:
Use PowerShell Core with PnP PowerShell
Avoid legacy modules like SharePoint Online Management Shell and classic PnP versions unless absolutely necessary.
Always reference internal column names when working with list data in scripts.
Whether you're just getting started or need a quick reference, these steps will help you avoid common pitfalls and script with confidence in the modern SharePoint Online environment.