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

MSFT_AADGroup: Unknown variable used in Set-TargetResource #5001

Closed
FJanneau opened this issue Aug 29, 2024 · 2 comments · Fixed by #5129 or #5132
Closed

MSFT_AADGroup: Unknown variable used in Set-TargetResource #5001

FJanneau opened this issue Aug 29, 2024 · 2 comments · Fixed by #5129 or #5132
Labels
Bug Something isn't working Entra ID V1.24.731.1 Version 1.24.731.1

Comments

@FJanneau
Copy link

Description of the issue

Hello,

In MSFT_AADGroup.psm1 file, line 570, the variable $assignedLicensesGUIDs is used in a condition.
As this variable is never used or declared before, the condition is always false and never executed.
So I wonder if this part should be removed or if a feature is missing in case this condition should be true.

    _if ($assignedLicensesGUIDs.Length -gt 0)
    {
        Set-MgGroupLicense -GroupId $currentGroup.Id -AddLicenses $licensesToAdd -RemoveLicenses @()
    }_

Kind regards.

Microsoft 365 DSC Version

V1.24.731.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

No response

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

No response

@salbeck-sit
Copy link
Contributor

I don't have time to test but it seems that $assignedLicensesGUIDs should be $licensesToAdd as the condition is part of ensuring that a group exists that previously didn't.

@andikrueger andikrueger added Bug Something isn't working Entra ID V1.24.731.1 Version 1.24.731.1 labels Sep 18, 2024
@salbeck-sit
Copy link
Contributor

The code in question is in fact never executed. However, the scriptblock following it takes care of things, so the block of code could be removed.
While at it, I tried to build unit-tests that verify that license-processing works as advertised. This in turn caused me to update the Test-TargetResource function so that DisabledPlans for each assigned licenses is processed per SkuId to clarify which license has differing DisabledPlans.
I have e PR ready that fixes the above

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