Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem exporting OrgSettings and PPTenantIsolationSettings #4783

Open
KarinaxRivera opened this issue Jun 21, 2024 · 11 comments
Open

Problem exporting OrgSettings and PPTenantIsolationSettings #4783

KarinaxRivera opened this issue Jun 21, 2024 · 11 comments

Comments

@KarinaxRivera
Copy link

KarinaxRivera commented Jun 21, 2024

I have been getting the below error messages when exporting PPTenantIsolationSettings and OrgSettings. For PowerPlatform, I have already completed adding the application as a service principal in PowerPlatform. For both workloads, I am authenticating using a certificate.

Microsoft 365 DSC Version

1.24.619.1

Which workloads are affected

Office 365 Admin, Power Platform

The DSC configuration

No response

Verbose logs showing the problem

o365 workload:
{ProtocolError}
Microsoft.Exchange.Management.RestApiClient.RestClientException: The following authorization requirements are not satisfied: ((TokenTypeAuthorizationRequirement(UserActAs, AppOnly)&ScopeAuthorizationRequirement(OrganizationSettings.Read, OrganizationSettings.ReadWrite, OrganizationSettings.Read, OrganizationSettings.ReadWrite))|WidsAuthorizationRequirement(62e90394-69f5-4237-9190-012177145e10,29232cdf-9323-42fd-ade2-1d097af3e4de,69091246-20e8-4a56-aa4d-066075b2a7a8,eb1f4a8d-243a-41f0-9fbd-c7cdf6c5ef7c)).
   at Microsoft.Exchange.Management.RestApiClient.M365Insights.WeveAdminCmdlet`2.HandleErrorResponse(HttpResponseMessage response, String settingsName)
   at Microsoft.Exchange.Management.RestApiClient.M365Insights.WeveAdminCmdlet`2.MakeAndSendGetRequest[T](String settingsName, Uri uri)
   at Microsoft.Exchange.Management.RestApiClient.Analytics.GetDefaultTenantMyAnalyticsFeatureConfig.InternalProcessRecord()
   at Microsoft.Exchange.Management.RestApiClient.AdminCmdlet`2.<ProcessRecord>b__34_0()
   at Microsoft.Exchange.Management.RestApiClient.AdminCmdlet`2.ExecuteWithExceptionHandling(Action action, Exception& exception)
"Error retrieving data:"
at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\DSCResources\MSFT_O365OrgSettings\MSFT_O365OrgSettings.psm1: line 294
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\DSCResources\MSFT_O365OrgSettings\MSFT_O365OrgSettings.psm1: line 1079
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCReverse.psm1: line 682
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCUtil.psm1: line 1356
at <ScriptBlock>, <No file>: line 51

powerapps workload:
{OperationStopped}
System.Management.Automation.RuntimeException: Invalid permission for the application. If you are using a custom app registration to authenticate, make sure it is defined as a Power Platform admin management application. For additional information refer to https://learn.microsoft.com/en-us/power-platform/admin/powershell-create-service-principal#registering-an-admin-management-application
"Error retrieving data:"
at Get-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\DSCResources\MSFT_PPTenantIsolationSettings\MSFT_PPTenantIsolationSettings.psm1: line 90
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\DSCResources\MSFT_PPTenantIsolationSettings\MSFT_PPTenantIsolationSettings.psm1: line 672
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCReverse.psm1: line 682
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCUtil.psm1: line 1356
at <ScriptBlock>, <No file>: line 1

Environment Information + PowerShell Version

No response

@andikrueger
Copy link
Collaborator

Could you please share a screenshot of the assigned API permissions for your application and the assigned roles? Thanks.

@KarinaxRivera
Copy link
Author

Could you please share a screenshot of the assigned API permissions for your application and the assigned roles? Thanks.

image
image
image

The app registration only has the Global Reader role and is a Power Platform admin management application.

@andikrueger
Copy link
Collaborator

Please check if you did assign:

OrganizationSettings.Read or if you need write access as well:

OrganizationSettings.ReadWrite

I did not see this API permission within the screenshot.

@KarinaxRivera
Copy link
Author

I do not see that permission listed in my Azure portal. I also checked which permissions the application would need using Get-M365DSCCompiledPermissionList and that API permission doesn't appear.

image

Could this be a problem with how my app registration was created?

@KarinaxRivera
Copy link
Author

Please check if you did assign:

OrganizationSettings.Read or if you need write access as well:

OrganizationSettings.ReadWrite

I did not see this API permission within the screenshot.

Is this a permission that I need to assign via PowerShell and not GUI?

@andikrueger
Copy link
Collaborator

You could add the permission by using Graph PowerShell or the EntraId Admin Center.

Using Graph PowerShell you need to add the scope parameter to Connect-MGGraph with one of the scopes above.

Within EntraID you could update your app registration in the section api permissions.

@ricmestre
Copy link
Contributor

ricmestre commented Jun 25, 2024

@andikrueger PP workload app doesn't require any API permissions, it just needs to be added to Power Apps as a mgmt app by an admin.

"Service principal applications are treated within Power Platform similar to how normal users are with the Power Platform Administrator role assigned. Granular roles and permissions can't be assigned to limit their capabilities. The application doesn't get any special role assigned in Microsoft Entra ID, as this is how platform services treat requests made by service principals."

https://microsoft365dsc.com/user-guide/get-started/authentication-and-permissions/#power-apps-permissions

https://learn.microsoft.com/en-us/power-platform/admin/powershell-create-service-principal#registering-an-admin-management-application

@andikrueger
Copy link
Collaborator

That is absolutely correct.

I was referring to the Exchange error message.

@ricmestre
Copy link
Contributor

Oh right, I didn't even see that resource there, O365 workload and specially O365OrgSettings is really a pain in the neck...

The log shows that it's failing on line 294 which corresponds for calling Get-DefaultTenantMyAnalyticsFeatureConfig, this requires either Global admin, EXO admin or Insights admin Entra roles as per https://learn.microsoft.com/en-us/powershell/module/exchange/get-defaulttenantmyanalyticsfeatureconfig?view=exchange-ps

In my case I've assigned Insights administrator since it's the most restrictive, please bear in mind that assigning any one of these Entra roles is required even if only reading is required.

@KarinaxRivera
Copy link
Author

After adding the Exchange Admin role, the error was fixed but generated new teams errors. Is there any specific roles/permissions needed to export the component TeamsM365App? The error I got was below:

{NotSpecified}
Microsoft.Teams.PowerShell.TeamsCmdlets.ErrorHandling.ApiException
at Microsoft.Teams.PowerShell.TeamsCmdlets.Utils.HttpUtilities.Get[T](HttpClient httpClient, Uri requestUri, Dictionary`2 headers)
at Microsoft.Teams.PowerShell.TeamsCmdlets.GetUnifiedApps.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
"Error during Export:"
at Export-TargetResource, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\DSCResources\MSFT_TeamsM365App\MSFT_TeamsM365App.psm1: line 438
at Start-M365DSCConfigurationExtract, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCReverse.psm1: line 682
at Export-M365DSCConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCUtil.psm1: line 1377
at , : line 1

@ricmestre
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants