When using Sites.Selected, the app registration has no access until you explicitly grant it permission to specific sites.

This step is required for:
  • OneDrive access
  • SharePoint Online access

Prerequisites

Before you begin,
  • You must have:
    • The App Registration Client ID
    • The Tenant ID
    • The target site URL
  • You must be signed in as an administrator with permission to manage SharePoint or OneDrive sites.

Identify the target site

  • OneDrive: Use the user’s OneDrive site URL. For example,
    https://<tenant>-my.sharepoint.com/personal/<user_identifier>
  • ShrePoint: Use the site collection URL. For example,
    https://<tenant>.sharepoint.com/sites/<site_name>

Grant access using PnP PowerShell

Use Microsoft’s PnP PowerShell module to assign the following permission levels.
  • Read
  • Write
  • Manage
  • FullControl
For example:
Grant-PnPAzureADAppSitePermission `
  -AppId "<client-id>" `
  -DisplayName "MOVEit Automation Access" `
  -Site "<site-url>" `
  -Permissions Read