microsoft/Microsoft365DSC

New-M365DSCDeltaReport: Error $typeStaticMethods = [] | gm - ... Missing type name after '['

ThoVos-CH opened this issue · 5 comments

Description of the issue

When creating a Delta Report of two configurations the commandlet New-M365DSCDeltaReport throws errors for every assignement in configuration files (Config below was for blueprint):

Invoke-Expression : In Zeile:1 Zeichen:63 + ... $typeStaticMethods = [] | gm - ... + ~ Der Typname nach "[" fehlt. In Zeile:4 Zeichen:46 + []::TryParse($subExpressi ... + ~ Der Typname nach "[" fehlt. In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.4\Modules\DSCParser.psm1:280 Zeichen:25 + ... Invoke-Expression -Command $scriptBlock | Out-N ... + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : ParserError: (:) [Invoke-Expression], ParseException + FullyQualifiedErrorId : MissingTypename,Microsoft.PowerShell.Commands.InvokeExpressionCommand

You can reproduce it with a Policy which has assignments in it. The error will be thrown also on commandlet Assert-M365DSCBlueprint.
The only workaround for me was to remove all assignments from all configurations (source and destination).

To be sure i:
Removed Module
Reinstalled Module
Update-M365DSCModule
Update-M365DSCDependencies
Uninstall-M365DSCOutdatedDependencies

Microsoft 365 DSC Version

1.24.515.2

Which workloads are affected

Intune

The DSC configuration

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

Configuration MyDefender
{
    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' 

    Node localhost
    {
        IntuneAntivirusPolicyWindows10SettingCatalog "IntuneAntivirusPolicyWindows10SettingCatalog-NEW"
        {
            allowbehaviormonitoring = "1";
            allowcloudprotection    = "1";
            Assignments             = @(
                MSFT_DeviceManagementConfigurationPolicyAssignments{
                    deviceAndAppManagementAssignmentFilterType = 'none'
                    groupDisplayName = 'Some Group'
                    dataType = '#microsoft.graph.groupAssignmentTarget'
                    groupId = 'MYID'
                }
            ); ### L2| No Comment
            Description             = ""; ### L2| No Comment
            DisplayName             = "NEW"; ### L2| No Comment
            Ensure                  = "Present"; ### L2| No Comment
            realtimescandirection   = "0"; ### L2| No Comment
        }
}

MyDefender -ConfigurationData .\ConfigurationData.psd1 -Credential $Credential

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Pro
OsOperatingSystemSKU : 48
OsArchitecture       : 64-Bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : de-DE
OsMuiLanguages       : {de-DE}

Name                           Value
----                           -----
PSVersion                      5.1.22621.2506
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.2506
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

I updated the Version of M365DSC to 1.24.522.1 and forced an update of all Dependencies. Still no luck.

@ThoVos-CH Did you already try the winrm quickconfig workaround from #4676? If yes, then can you please attach the output of $error (best in a .txt file) from the PowerShell session?

@FabienTschanz I just confirmed that enabling WinRM fixes this problem on my DevOps pipelines, although setting it up there involves a little bit more work than winrm quickconfig, but locally that's the way to go.

@FabienTschanz That did the trick. My Winrm Service was deactivated. After running winrm quickconfig, no errors.