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

Fix RequiredResourceAccess cannot be an array issue in Set-AzureADMSApplication #1229

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

PenguinCats
Copy link

@PenguinCats PenguinCats commented Nov 22, 2024

Why we have this PR

When using Set-EntraApplication -ApplicationId $application.Id -RequiredResourceAccess $requiredResourceAccess, the $requiredResourceAccess could be an array. For example:

$requiredResourceAccess = @(
    @{resourceAppId = '00000003-0000-0000-c000-000000000000'
        resourceAccess = @(
        @{
            id = 'c79f8feb-a9db-4090-85f9-90d820caa0eb'
            type = 'Scope'
        },
        @{
            id = '9a5d68dd-52b0-4cc2-bd40-abcf44ac3a30'
            type = 'Role'
        })
    },
    @{resourceAppId = '11111111-0000-0000-c000-000000000000'
        resourceAccess = @(
        @{
            id = '11111111-a9db-4090-85f9-90d820caa0eb'
            type = 'Scope'
        },
        @{
            id = '11111111-52b0-4cc2-bd40-abcf44ac3a30'
            type = 'Role'
        })
    }
)
Set-EntraApplication -ApplicationId $application.Id -RequiredResourceAccess $requiredResourceAccess

In current logic, the input array will be converted into a single json string. However, the Set-EntraApplication is actually calling Update-MgApplication command, which requires input -RequiredResourceAccess <IMicrosoftGraphRequiredResourceAccess[]>. Reference here. This single string cannot be converted into IMicrosoftGraphRequiredResourceAccess[], causing the following error:
image

How to fix in the PR

We convert the parameter into string[], each json string can be converted into IMicrosoftGraphRequiredResourceAccess correctly.

Copy link

Learn Build status updates of commit 11f6329:

✅ Validation status: passed

File Status Preview URL Details
module/Entra/customizations/Set-EntraApplication.ps1 ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

@PenguinCats PenguinCats marked this pull request as ready for review November 22, 2024 15:43
@PenguinCats PenguinCats requested a review from a team as a code owner November 22, 2024 15:43
@PenguinCats PenguinCats reopened this Nov 22, 2024
Copy link

Learn Build status updates of commit 11f6329:

✅ Validation status: passed

File Status Preview URL Details
module/Entra/customizations/Set-EntraApplication.ps1 ✅Succeeded

For more details, please refer to the build report.

For any questions, please:

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

Successfully merging this pull request may close these issues.

1 participant