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

ConvertTo-DscObject busted again with nested properties in some cases #34

Closed
ricmestre opened this issue Jul 11, 2023 · 7 comments
Closed

Comments

@ricmestre
Copy link
Contributor

ricmestre commented Jul 11, 2023

It seems that sometimes ConvertTo-DscObject still misbehaves, take a look at the blueprint at the bottom then check this, the Settings property inside $Resource has other properties inside that should be actually be nested inside Settings.SettingInstance (such as Value or odataType)

PS C:\> $Resource.Settings  

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphdeviceManagementConfigurationSetting
SettingInstance                {CIMInstance, choiceSettingValue}
Value                          device_vendor_msft_policy_config_updatev83diff~policy~cat_edgeupdate~cat_applications_pol_defaultcreatedesktopshortcut_0
SettingDefinitionId            device_vendor_msft_policy_config_updatev83diff~policy~cat_edgeupdate~cat_applications_pol_defaultcreatedesktopshortcut
odataType                      #microsoft.graph.deviceManagementConfigurationChoiceSettingInstance

But in this case Settings.SettingInstance is actually empty where it shouldn't.

PS C:\> $Resource.Settings.SettingInstance

Name                           Value
----                           -----
CIMInstance                    MSFT_MicrosoftGraphDeviceManagementConfigurationSettingInstance
choiceSettingValue

Blueprint

# Generated with Microsoft365DSC version 1.23.705.1
# For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC
param (
    [parameter()]
    [System.Management.Automation.PSCredential]
    $Credential
)

Configuration Custom
{
    param (
        [parameter()]
        [System.Management.Automation.PSCredential]
        $Credential
    )

    if ($null -eq $Credential)
    {
        <# Credentials #>
        $Credscredential = Get-Credential -Message "Credentials"

    }
    else
    {
        $CredsCredential = $Credential
    }

    $OrganizationName = $CredsCredential.UserName.Split('@')[1]

    Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.23.705.1'

    Node localhost
    {
        IntuneSettingCatalogCustomPolicyWindows10 "IntuneSettingCatalogCustomPolicyWindows10-TEST"
        {
            Assignments          = @();
            Credential           = $Credscredential;
            Description          = "Test";
            Ensure               = "Present";
            Id                   = "495a239d-4367-474f-86e8-225d9f6bbe11";
            Name                 = "Setting Catalogue- Block MS Edge Shortcuts";
            Platforms            = "windows10";
            Settings             = @(
                MSFT_MicrosoftGraphdeviceManagementConfigurationSetting{
                    SettingInstance = MSFT_MicrosoftGraphDeviceManagementConfigurationSettingInstance{
                        choiceSettingValue = MSFT_MicrosoftGraphDeviceManagementConfigurationChoiceSettingValue{
                            Value = 'device_vendor_msft_policy_config_updatev83diff~policy~cat_edgeupdate~cat_applications_pol_defaultcreatedesktopshortcut_0'
                        }
                        SettingDefinitionId = 'device_vendor_msft_policy_config_updatev83diff~policy~cat_edgeupdate~cat_applications_pol_defaultcreatedesktopshortcut'
                        odataType = '#microsoft.graph.deviceManagementConfigurationChoiceSettingInstance'
                    }
                }
            );
            Technologies         = "mdm";
        }
    }
}

Custom -ConfigurationData .\ConfigurationData.psd1 -Credential $Credential
@ricmestre
Copy link
Contributor Author

@NikCharlebois Just to let you know this is still happening with latest version.

@ricmestre
Copy link
Contributor Author

@NikCharlebois Any chance in looking at this? I had a call early this morning where a manager told me that they are creating all policies as Settings Catalog but in order to use our solution we need to have this bug fixed otherwise they won't consider using DSC at all.

@ricmestre
Copy link
Contributor Author

ricmestre commented Nov 16, 2023

Here's another test resource which also has the same problem IntuneDeviceConfigurationKioskPolicyWindows10

        IntuneDeviceConfigurationKioskPolicyWindows10 "IntuneDeviceConfigurationKioskPolicyWindows10-IntuneDeviceConfigurationKioskPolicyWindows10_1"
        {
            ApplicationId                       = $IntuneApplicationId;
            Assignments                         = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    dataType = '#microsoft.graph.groupAssignmentTarget'
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupId = 'b0b8fd3f-af2a-453b-be57-80182d599f02'
                }
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    dataType = '#microsoft.graph.exclusionGroupAssignmentTarget'
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupId = '053dc89a-be83-411a-bad3-909904b7239e'
                }
            );
            CertificateThumbprint               = $IntuneCertThumbprint;
            DisplayName                         = "IntuneDeviceConfigurationKioskPolicyWindows10_1";
            EdgeKioskEnablePublicBrowsing       = $False;
            Ensure                              = "Present";
            Id                                  = "7fea73fd-20d3-439a-9fa4-73955e082dc5";
            KioskBrowserDefaultUrl              = "http://bing.com";
            KioskBrowserEnableEndSessionButton  = $False;
            KioskBrowserEnableHomeButton        = $True;
            KioskBrowserEnableNavigationButtons = $False;
            KioskProfiles                       = @(
                MSFT_MicrosoftGraphwindowsKioskProfile{
                    AppConfiguration = MSFT_MicrosoftGraphWindowsKioskAppConfiguration{
                        odataType = '#microsoft.graph.windowsKioskSingleWin32App'
                        Win32App = MSFT_MicrosoftGraphWindowsKioskWin32App{
                            AppType = 'unknown'
                            AutoLaunch = $False
                            ClassicAppPath = 'msedge.exe'
                            EdgeKiosk = 'https://domain.com'
                            EdgeKioskType = 'publicBrowsing'
                            EdgeNoFirstRun = $True
                            StartLayoutTileSize = 'hidden'
                        }
                    }
                    ProfileId = '17f9e980-3435-4bd5-a7a1-ca3c06d0bf2c'
                    ProfileName = 'profile'
                    UserAccountsConfiguration = @(
                        MSFT_MicrosoftGraphWindowsKioskUser{
                            odataType = '#microsoft.graph.windowsKioskAutologon'
                        }
                    )
                }
            );
            TenantId                            = $OrganizationName;
            WindowsKioskForceUpdateSchedule     = MSFT_MicrosoftGraphwindowsKioskForceUpdateSchedule{
                RunImmediatelyIfAfterStartDateTime = $False
                StartDateTime = '2023-04-15T23:00:00.0000000+00:00'
                DayofMonth = 1
                Recurrence = 'daily'
                DayofWeek = 'sunday'
            };
        }

@ykuijs
Copy link
Member

ykuijs commented Feb 14, 2024

Fixed in PR #36

@ykuijs
Copy link
Member

ykuijs commented Feb 14, 2024

Issue can be closed

@FabienTschanz
Copy link
Contributor

@ricmestre You can close this issue, should already be fixed.

@ricmestre
Copy link
Contributor Author

Completely forgot about this, yes it can be closed since it was already fixed.

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

No branches or pull requests

3 participants