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

Error when converting exported M365DSC tenant config with Convert-M365DSCExportToPowerShellDataFile #19

Open
msftep opened this issue Jun 12, 2024 · 5 comments

Comments

@msftep
Copy link

msftep commented Jun 12, 2024

Hello,

I encounter the same error when attempting to convert any exported workload using Convert-M365DSCExportToPowerShellDataFile:

At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:280 char:25
+ ...                       Invoke-Expression -Command $scriptBlock | Out-N ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
    + FullyQualifiedErrorId : MissingTypename,Microsoft.PowerShell.Commands.InvokeExpressionCommand

Invoke-Expression : At line:1 char:63
+ ...                                        $typeStaticMethods = [] | gm - ...
+                                                                  ~
Missing type name after '['.
At line:4 char:46
+                                             []::TryParse($subExpressi ...
+                                              ~
Missing type name after '['.

M365DSC version 1.24.605.1
All dependencies are updated.

Many thanks.
Cheers.,

T.

@ykuijs
Copy link
Owner

ykuijs commented Jun 19, 2024

Hi @jesthepp, I am currently working on the release of the new version of the whitepaper. The function you are referring to didn't get the attention it should have gotten since we are currently not using that in the whitepaper. But it is on my backlog to improve when that is done.

Could you please share a little more info, like the config you have exported? That makes troubleshooting much easier.

@msftep
Copy link
Author

msftep commented Jun 25, 2024

Hello Yorick,

Thanks for your feedback. I had opened this issue before I had a chance to beta-test the new whitepaper, so I assumed you were still working on it :-) As I mentioned to you by e-mail, my aim is to export my tenant's current settings and integrate them into the basic configuration of the composite resources I use.

To do this, I've exported my tenant's configuration using the following command and different versions of M365DSC (1.24.619.1 and 1.24.612.1). I used the following command:

Export-M365DSCConfiguration -Workload AAD -Mode Full -ApplicationId $ApplicationId -ApplicationSecret $ApplicationSecret -TenantId $TenantId

In this case, it was for AAD, but I've also tested other workloads (Intune, Sharepoint, ...) and I'm having the same problem.
Here are the errors that appear when executing the following command:

Convert-M365DSCExportToPowerShellDataFile -SourceFile "C:\DevOps\TestPhase01\DSC Testing Phase\M365TenantConfig.ps1" -ResultFolder "C:\DevOps\TestPhase01\DSC Testing Phase\Results"

Error (always the same, in a loop):

Invoke-Expression : At line:1 char:63
+ ...                                        $typeStaticMethods = [] | gm - ...
+                                                                  ~
Missing type name after '['.
At line:4 char:46
+                                             []::TryParse($subExpressi ...
+                                              ~
Missing type name after '['.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:280 char:25
+ ...                       Invoke-Expression -Command $scriptBlock | Out-N ...
+                           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ParserError: (:) [Invoke-Expression], ParseException
    + FullyQualifiedErrorId : MissingTypename,Microsoft.PowerShell.Commands.InvokeExpressionCommand

For my tests, I always used the last version of M365DSCTools within an admin PowerShell session. I also tried enabling and disabling M365DSCTelemetryOption with the same result.

I hope I've given you enough information. If not, please come back to me.

Many thanks.
Cheers,

T.

@ykuijs
Copy link
Owner

ykuijs commented Jul 3, 2024

To troubleshoot this issue, could you please share the exported config you are using. You can share it via email if it contains sensitive information.

@ykuijs
Copy link
Owner

ykuijs commented Sep 11, 2024

Hi @msftep, sorry for the late reply.....the vacation period came in between.

Are you by any chance running this cmdlet on a Windows 10 or 11 machine? I recently have been working with another customer that experienced the same issue when running on a Windows client OS. On those, PowerShell Remoting is disabled by default and this function is using the LCM which relies on Windows Remoting.

To resolve the issue, you have to run winrm quickconfig once in an elevated PowerShell or Command Prompt window.

@martincaddick
Copy link

@ykuijs , The winrm quickconfig worked great for me.

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