microsoft/Microsoft365DSC

DSCParser error when generating reports.

Kimhal opened this issue ยท 11 comments

Description of the issue

When I run the following command.
New-M365DSCReportFromConfiguration -Type 'Excel' -ConfigurationPath 'D:\Microsoft365DSC\Configuration.ps1' -OutputPath 'D:\Microsoft365DSC\Report.xlsx'
I receive the this error:
**Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.4\Modules\DSCParser.psm1:420 char:9

  •     $resourceType         = $resource.CommandElements[0].Value
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                        
         + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
         + FullyQualifiedErrorId : NullArray**
    

Microsoft 365 DSC Version

1.24.515.1

Which workloads are affected

other

The DSC configuration

No response

Verbose logs showing the problem

No response

Environment Information + PowerShell Version

OsName               : Microsoft Windows 11 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 22621.1.amd64fre.ni_release.220506-1250
OsLanguage           : da-DK
OsMuiLanguages       : {da-DK, en-US}

@Kimhal Can you provide a DSC configuration to reproduce the issue?

@Kimhal I don't receive the error you mentioned, but another one ( Invoke-Expression, Missing type name after [ ). Silly question: Are you running the command in an administrative prompt? In my case it then succeeds.

@FabienTschanz I'm running the command in a elevated prompt, but you are right about the error. I'm also is getting the ( Invoke-Expression, Missing type name after [ ) error. And like you it succeeds with generating a report.
But still, there is something wrong with the parser.

@Kimhal When I run your exact configuration in an elevated prompt, it works without any issues. The parser works as it is supposed to do in that case, unfortunately I am unable to reproduce your issue. No errors can be seen on the console.

Can you try executing the command in an elevated Windows PowerShell (x64) session with Microsoft365DSC version 1.24.515.2 and the exact same configuration you sent? Please make sure to use Uninstall-M365DSCOutdatedDependencies before to get rid of any previous versions laying around.

If there is an error, please post the result of $Error | select *. This shows the errors and where they appeared. Especially useful there is the Exception and the ScriptStackTrace.

@FabienTschanz I've also had this issue once I installed 1.24.515.2 (which uses DSCParser v2, the code in question doesn't exist in v1) with my own different blueprints, somehow the error message went away and I cannot explain why.

Nevertheless DSCParser also has other issues, see #4681, which I've already reported to @NikCharlebois

@FabienTschanz I have updated the Microsoft365DSC module and run a Uninstall-M365DSCOutdatedDependencies.
I'm still getting errors, but the report is generated. The @error is attached in a txt file.
error.txt

I initially had the error Cannot index into a null array but as explained that went away, nevertheless the error that @Kimhal is reporting now I still have it present with my configuration so there's definitely something going wrong here with the parser.

@Kimhal Thank you very much for the error log. While searching in there, I discovered that the parser does not find the associated CIM type because it cannot connect to the CIM service. The logged error message is the following:

The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: ""winrm quickconfig"

What happens if you run winrm quickconfig and then try it again? A restart shouldn't be necessary. No idea how it is on a Azure DevOps Pipeline, maybe @ricmestre you know the answer to that.

Makes sense since it calls Get-CimClass, regarding the containers in the pipelines they always need WinRM to be enabled whenever I'm performing deployments, since they are ephemeral, nevertheless my unit tests don't initialize it since it was never needed before like it seems to be now.

I'm super busy right now and can't check it but most likely that would solve the problem for me.

thanks guys. That worked for me.๐Ÿ˜๐Ÿ˜
I am running the Microsoft365dsc version. 1.24.522.1 and DSCParser version 2.0.0.4.