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

  1. In the Microsoft Entra admin center, go to App registrations and click New registration.
  2. Give the app a name. Peter calls it PS-SPAPI, but any name works.
  3. Keep Single tenant only.
  4. Under Redirect URI, choose Public client and enter http://localhost.
  5. Click Register. The app opens on its overview.
  6. Copy the Application (client) ID. That is the Client ID a PowerShell script asks for.

Give the app SharePoint permission

  1. Go to API permissions and click Add a permission.
  2. Choose SharePoint >Delegated permissions and select AllSites.FullControl.
  3. Click Add permissions. The permission is listed under Configured permissions, together with User.Read, which every new app has.
  4. 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:
Connect-PnPOnline -Url https://contoso.sharepoint.com/sites/Sales -Interactive -ClientId <your Client ID>


In the next article, a certificate lets a script connect to SharePoint Online without an interactive sign-in.

back icon next icon
Products Buy Services Tips Books Contact About Us Tools

Security and integrity

Copyright  Kalmstrom Enterprises AB  All rights reserved