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

IntuneDeviceRemediation: Cannot deploy if group in Assignments doesn't exist #5856

Open
ricmestre opened this issue Feb 28, 2025 · 0 comments · May be fixed by #5857
Open

IntuneDeviceRemediation: Cannot deploy if group in Assignments doesn't exist #5856

ricmestre opened this issue Feb 28, 2025 · 0 comments · May be fixed by #5857

Comments

@ricmestre
Copy link
Contributor

Description of the issue

In order to have a stable version running I'm still on 1.24.731.1, with several backported fixes on top, but there's an issue on IntuneDeviceRemediation which still affects latest version, if Assignments contain a group that doesn't exist in the tenant then the Graph request will fail since it tries to send a null target.

I have a patch which I've tested successfully in my dev tenant that fixes this issue, essentially it uses Update-DeviceConfigurationPolicyAssignment like every other resource nowadays, which already handles this situation, instead of sending the request directly via Invoke-MgGraphRequest. I'll send the fix in a few minutes.

Microsoft 365 DSC Version

1.24.731.1

Which workloads are affected

Intune

The DSC configuration

IntuneDeviceRemediation "IntuneDeviceRemediation-IntuneDeviceRemediation_1"
        {
            ApplicationId            = $IntuneApplicationId;
            Assignments              = @(
                MSFT_IntuneDeviceRemediationPolicyAssignments{
                    RunSchedule = MSFT_IntuneDeviceRemediationRunSchedule{
                        Interval = 1
                        DataType = '#microsoft.graph.deviceHealthScriptHourlySchedule'
                    }
                    RunRemediationScript = $False
                    Assignment = MSFT_DeviceManagementConfigurationPolicyAssignments{
                        deviceAndAppManagementAssignmentFilterId = '00000000-0000-0000-0000-000000000000'
                        deviceAndAppManagementAssignmentFilterType = 'none'
                        groupDisplayName = 'ThisGroupDoesNotExist'
                        dataType = '#microsoft.graph.groupAssignmentTarget'
                        groupId = 'deadbeef-ffff-ffff-ffff-deadbeefdead'
                    }
                }
            );
            CertificateThumbprint    = $IntuneCertThumbprint;
            Description              = "";
            DetectionScriptContent   = "base64script";
            DeviceHealthScriptType   = "deviceHealthScript";
            DisplayName              = "IntuneDeviceRemediation_1";
            EnforceSignatureCheck    = $False;
            Ensure                   = "Present";
            Id                       = "deadbeef-ffff-ffff-ffff-deadbeefdead";
            Publisher                = "M365DSC";
            RemediationScriptContent = "";
            RoleScopeTagIds          = @("0");
            RunAs32Bit               = $True;
            RunAsAccount             = "system";
            TenantId                 = $OrganizationName;
        }

Verbose logs showing the problem

Response status code does not indicate success: BadRequest (Bad Request).
...
+ FullyQualifiedErrorId : InvokeGraphHttpResponseException,Microsoft.Graph.PowerShell.Authentication.Cmdlets.InvokeMgGraphRequest

Environment Information + PowerShell Version

Win11/PS5.1
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 a pull request may close this issue.

1 participant