Create an Entra App for PnP PowerShell in SharePoint
Online
A PowerShell with SharePoint tutorial
Before a PnP PowerShell script can sign in to SharePoint
Online, it needs an Entra app registration that gives PowerShell
permission to use the SharePoint API. This app is not tied
to a specific product or script.
The app and its
Client ID are shared by everyone in the tenant, so it only
has to be created once. Admin consent is also given once
for the whole tenant.
Each person who runs a script
still needs permission in SharePoint for what the script
does, for example to create lists on a site or to manage
sites as a SharePoint administrator.
In the demo
below, Peter Kalmström creates the app in the Microsoft
Entra admin center and gives it the SharePoint permission
it needs.
Register the app
In the Microsoft Entra admin center, go to App
registrations and click New registration.
Give the app a name. Peter calls it PS-SPAPI, but
any name works.
Keep Single tenant only.
Under Redirect URI, choose Public client
and enter http://localhost.
Click Register. The app opens on its overview.
Copy the Application (client) ID. That is
the Client ID a PowerShell script asks for.
Give the app SharePoint permission
Go to API permissions and click Add a
permission.
Choose SharePoint >Delegated permissions
and select AllSites.FullControl.
Click Add permissions. The permission is
listed under Configured permissions, together
with User.Read, which every new app has.
Click Grant admin consent and confirm with
Yes. Both permissions now show Granted.
The permission is delegated, so a script can only do what
the signed-in user may do. The person who runs the script
must be a SharePoint administrator.
Use the app in your scripts
Give the Client ID to every PnP PowerShell script that works
with SharePoint Online, for example: