To grant permissions on the respective site collections to be scanned via TreeSize/SpaceObServer, the PowerShell cmdlet Grant-PnPAzureADAppSitePermission can be used.
- Import-Module PnP.Powershell
- Connect-PnPOnline -Url <SharePointSIteURL> -Interactive
- Grant-PnPAzureADAppSitePermission -AppId <AzureAppID> -DisplayName <AzureAppName> -Site < SharePointSiteURL> -Permissions write
The user that is used for granting the permission must be a site collection admin of the respective site collection. The role 'Owner' is not sufficient.
For more information about the used cmdlets please see: https://pnp.github.io/powershell/cmdlets/