Skip to main content

SharePoint Online

PowerShell for administering SharePoint Online with PnP.PowerShell. Connect to the admin endpoint once (see Microsoft 365 — Overview & Connection) and every script here works from that session.

Scripts​

Before the first run​

PnP.PowerShell 2.x removed the built-in multi-tenant Entra application, so an interactive connection now needs your own app registration. Do this once:

Register-PnPEntraIDAppForInteractiveLogin `
-ApplicationName 'ShadowIT-PnP-Admin' `
-Tenant 'yourtenant.onmicrosoft.com' `
-Interactive

Keep the client ID it returns and pass it as -ClientId to every script here. An AADSTS700016 or an unexpected consent prompt on connect almost always means this step hasn't been done.

Tip — The admin endpoint, not the root site

These scripts connect to https://<tenant>-admin.sharepoint.com, not https://<tenant>.sharepoint.com. Connecting to the wrong one produces cmdlet-not-found errors that look like a module problem.