microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.64k stars 505 forks source link

IntuneDeviceConfigurationPolicyAndroidDeviceOwner: Cannot deploy if DetailedHelpText, DeviceOwnerLockScreenMessage or ShortHelpText are defined #5411

Closed ricmestre closed 2 weeks ago

ricmestre commented 2 weeks ago

Description of the issue

IntuneDeviceConfigurationPolicyAndroidDeviceOwner can define the properties DetailedHelpText, DeviceOwnerLockScreenMessage or ShortHelpText, which are a CIM instance of type MSFT_MicrosoftGraphandroiddeviceowneruserfacingmessage, but if they are in the configuration then when trying to deploy the policy it fails with Request is invalid.

It looks like the problem is being caused by the CIM instance being sent without the @odata.type which should be set to #microsoft.graph.androidDeviceOwnerUserFacingMessage

Microsoft 365 DSC Version

1.24.1113.1

Which workloads are affected

Intune

The DSC configuration

IntuneDeviceConfigurationPolicyAndroidDeviceOwner "IntuneDeviceConfigurationPolicyAndroidDeviceOwner-IntuneDeviceConfigurationPolicyAndroidDeviceOwner_1"
        {
            AppsAllowInstallFromUnknownSources             = $False;
            AppsDefaultPermissionPolicy                    = "autoGrant";
            AppsRecommendSkippingFirstUseHints             = $False;
            Assignments                                    = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupDisplayName = 'DummyGroupInclude'
                    dataType = '#microsoft.graph.groupAssignmentTarget'
                    groupId = '1e503d88-4cde-4c67-8595-1d3e62618f21'
                }
            );
            AzureAdSharedDeviceDataClearApps               = @();
            Credential                                     = $CredsCredential;
            CrossProfilePoliciesAllowCopyPaste             = $True;
            CrossProfilePoliciesAllowDataSharing           = "notConfigured";
            DetailedHelpText                               = MSFT_MicrosoftGraphandroiddeviceowneruserfacingmessage{
                DefaultMessage = 'Contact Servicedesk in need of support.'
            };
            DeviceOwnerLockScreenMessage                   = MSFT_MicrosoftGraphandroiddeviceowneruserfacingmessage{
                DefaultMessage = 'Contact Servicedesk in need of support.'
            };
            DisplayName                                    = "IntuneDeviceConfigurationPolicyAndroidDeviceOwner_1";
            EnrollmentProfile                              = "notConfigured";
            Ensure                                         = "Present";
            FactoryResetDeviceAdministratorEmails          = @();
            Id                                             = "b1342588-3c4b-4c41-a569-d6a64ba31d13";
            KioskCustomizationStatusBar                    = "notConfigured";
            KioskCustomizationSystemNavigation             = "notConfigured";
            KioskModeAppPositions                          = @();
            KioskModeApps                                  = @();
            KioskModeManagedFolders                        = @();
            KioskModeUseManagedHomeScreenApp               = "notConfigured";
            KioskModeWifiAllowedSsids                      = @();
            PasswordBlockKeyguardFeatures                  = @();
            PasswordMinutesOfInactivityBeforeScreenTimeout = 10;
            PasswordPreviousPasswordCountToBlock           = 5;
            PasswordRequiredType                           = "required";
            PasswordRequireUnlock                          = "deviceDefault";
            PersonalProfilePersonalApplications            = @();
            PersonalProfilePlayStoreMode                   = "notConfigured";
            PersonalProfileScreenCaptureBlocked            = $False;
            ScreenCaptureBlocked                           = $False;
            SecurityDeveloperSettingsEnabled               = $True;
            SecurityRequireVerifyApps                      = $True;
            ShortHelpText                                  = MSFT_MicrosoftGraphandroiddeviceowneruserfacingmessage{
                DefaultMessage = 'Contact Servicedesk for support.'
            };
            StayOnModes                                    = @();
            SystemUpdateFreezePeriods                      = @();
            VpnAlwaysOnLockdownMode                        = $False;
            VpnAlwaysOnPackageIdentifier                   = "";
            WorkProfilePasswordRequiredType                = "deviceDefault";
            WorkProfilePasswordRequireUnlock               = "deviceDefault";
        }

Verbose logs showing the problem

The request is invalid.
+ CategoryInfo          : InvalidOperation: ({ Headers = , b...Configuration }:) [], CimException
+ FullyQualifiedErrorId : Microsoft.Graph.Beta.PowerShell.Cmdlets.NewMgBetaDeviceManagementDeviceConfiguration_Create
+ PSComputerName        : localhost

Environment Information + PowerShell Version

Win11/PS5.1
ricmestre commented 2 weeks ago

I patched the resource to send '@odata.type' set to #microsoft.graph.androidDeviceOwnerUserFacingMessage in the CIM instance and I see it being sent in the request but it still fails.

The problem is really with these 3 properties, if I remove them from the request being sent the resource is deployed without issues so not sure exactly what the issue is.

FabienTschanz commented 2 weeks ago

@ricmestre Do you want me to take a look at it?

ricmestre commented 2 weeks ago

@FabienTschanz Thank you Fabien, I think I got it, LocalizedMessages must always be sent in those requests even if they're null.

I'll raise a PR with the fix.

FabienTschanz commented 2 weeks ago

Alright 👍