microsoft/Microsoft365DSC

IntuneWindowsAutopilotDeploymentProfileAzureADJoined: Creates New Resource Every Run

AnthonyKersten opened this issue · 2 comments

Description of the issue

When I run Start-DSCConfiguration with the example of this resource:

Configuration Example
{
    param(
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $Credscredential
    )
    Import-DscResource -ModuleName Microsoft365DSC

    node localhost
    {
        IntuneWindowsAutopilotDeploymentProfileAzureADJoined 'Example'
        {
            Assignments                = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    dataType = '#microsoft.graph.allDevicesAssignmentTarget'
                }
            );
            Credential                 = $Credscredential;
            Description                = "";
            DeviceNameTemplate         = "test";
            DeviceType                 = "windowsPc";
            DisplayName                = "AAD";
            EnableWhiteGlove           = $False; # Updated Property
            Ensure                     = "Present";
            ExtractHardwareHash        = $True;
            Language                   = "";
            OutOfBoxExperienceSettings = MSFT_MicrosoftGraphoutOfBoxExperienceSettings1{
                HideEULA = $False
                HideEscapeLink = $True
                HidePrivacySettings = $True
                DeviceUsageType = 'singleUser'
                SkipKeyboardSelectionPage = $True
                UserType = 'administrator'
            };
        }
    }
}

When I run this repeatedly, it creates additional Deployment Profiles each time instead of maintaining idempotency.

Microsoft 365 DSC Version

1.24.612.1

Which workloads are affected

Intune

The DSC configuration

Configuration Example
{
    param(
        [Parameter(Mandatory = $true)]
        [PSCredential]
        $Credscredential
    )
    Import-DscResource -ModuleName Microsoft365DSC

    node localhost
    {
        IntuneWindowsAutopilotDeploymentProfileAzureADJoined 'Example'
        {
            Assignments                = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    dataType = '#microsoft.graph.allDevicesAssignmentTarget'
                }
            );
            Credential                 = $Credscredential;
            Description                = "";
            DeviceNameTemplate         = "test";
            DeviceType                 = "windowsPc";
            DisplayName                = "AAD";
            EnableWhiteGlove           = $False; # Updated Property
            Ensure                     = "Present";
            ExtractHardwareHash        = $True;
            Language                   = "";
            OutOfBoxExperienceSettings = MSFT_MicrosoftGraphoutOfBoxExperienceSettings1{
                HideEULA = $False
                HideEscapeLink = $True
                HidePrivacySettings = $True
                DeviceUsageType = 'singleUser'
                SkipKeyboardSelectionPage = $True
                UserType = 'administrator'
            };
        }
    }
}

Verbose logs showing the problem

VERBOSE: Perform operation 'Invoke CimMethod' with following parameters, ''methodName' = SendConfigurationApply,'className' = MSFT_DSCLocalConfigurationManager,'namespaceName' = root/Microsoft/Windows/DesiredStateConfigurati
on'.
VERBOSE: An LCM method call arrived from computer PC-NSDKLA8A with user sid S-1-12-1-618740431-1228566745-1314046445-505783123.
VERBOSE: [PC-NSDKLA8A]: LCM:  [ Start  Set      ]
VERBOSE: [PC-NSDKLA8A]: LCM:  [ Start  Resource ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]
VERBOSE: [PC-NSDKLA8A]: LCM:  [ Start  Test     ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]
VERBOSE: [PC-NSDKLA8A]:                            [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example] Testing configuration of the Intune Windows Autopilot Deployment Profile Azure AD Joined with Id {} and Displ
ayName {AAD}
VERBOSE: [PC-NSDKLA8A]:                            [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example] Test-TargetResource returned False
VERBOSE: [PC-NSDKLA8A]: LCM:  [ End    Test     ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]  in 1.2720 seconds.
VERBOSE: [PC-NSDKLA8A]: LCM:  [ Start  Set      ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]
VERBOSE: [PC-NSDKLA8A]:                            [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example] Creating an Intune Windows Autopilot Deployment Profile Azure AD Joined with DisplayName {AAD}
VERBOSE: [PC-NSDKLA8A]: LCM:  [ End    Set      ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]  in 1.0680 seconds.
VERBOSE: [PC-NSDKLA8A]: LCM:  [ End    Resource ]  [[IntuneWindowsAutopilotDeploymentProfileAzureADJoined]Example]

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Business
OsOperatingSystemSKU : 48
OsArchitecture       : 64 bits
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : en-US
OsMuiLanguages       : {en-US, nl-NL}

Key   : PSVersion
Value : 5.1.22621.2506
Name  : PSVersion

Key   : PSEdition
Value : Desktop
Name  : PSEdition

Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions

Key   : BuildVersion
Value : 10.0.22621.2506
Name  : BuildVersion

Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion

Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion

Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion

Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion

Try to add the field Id to your blueprint, the value inside doesn't actually matter, then compile to MOF and try the deployment again.

Ah yes, that works. So it seems that te example itself is not correct. It should have an Id there as well.
Thanks!