PowerBI’s admin-level API’s are not enabled at the OAuth / Entra level, but need to be enabled in the PowerBI Admin Center before you can use M365Permissions to scan all your PowerBI resources for access.
If you want to use the M365Permissions module in unattended (or headless) mode, e.g. from a runbook or on a server as scheduled task, you’ll need to create an app registration in Entra with sufficient permissions to scan your tenant.
Setup instructions (automated)
Install the module using Install-Module-NameM365Permissions-Force
Load the module using Import-Module-NameM365Permissions
Create a service principal using Set-ScanPermissions -switchToSPNAuth-appName "M365Permissions (AppOnly)"
Add the new app registration to the global administrator role:
Run set-M365PermissionsConfig -LCTenantId <tenant ID> -LCClientId <client id> with the values from step 5 to configure the module to use your new SPN to log in.
Alternatively, you can configure the LCTENANTID and LCCLIENTID environment variables with above information.
If you also configure the LCAUTHMODE environment variable with a value of “ServicePrincipal”, the module will log in to your tenant fully automatically the moment it is imported.
If you’re running interactively, you can now use connect-M365 -ServicePrincipal before running a scan to use the SPN instead of delegated authentication
If you want to run from an automation account, Azure function etc, for now you’ll have to retrieve the .pfx file dynamically and install it before the module loads because the module looks in the local certificate store for a certificate with your tenant ID as subject.
I will consider adding support for Managed Identities in the future to make this simpler, and possibly also add keyvault integration or direct path configuration an option.
Restrictions
When scanning as service principal, you cannot scan:
Graph Subscriptions
PowerBI Gateways
You’ll see a warning in the logs about this as they’ll automatically be excluded.
Well, a lot to share today! 36 commits with plenty of quality of life stuff, and some nice new features such as automatic retry of jobs when scanning multiple sources (e.g. all mailboxes). Since retrying runs the risk of getting duplicate results in the report, I’ve also added a deduplication function. Also handy for those of you who run over time and add to the same report file or want to merge reports but don’t want to deduplicate manually.
File based caching should also further improve runs over larger environments that take more than a few hours.
Today’s release focuses on efficiency and bugfixes, no real new features other than some parameters which were moved to the set-M365PermissionsConfig function instead of having to be passed to each command.
Full changelog:
[Feature] Move outputFormat parameter to persistent config
[Feature] Move includeCurrentUser parameter to persistent config
[Feature] Add Verbose parameter to persistent config
[Feature] Faster enumeration when running concurrent jobs