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

Export: Unable to create reports from configuration exports #4779

Open
ChrisFisherAllianceIT opened this issue Jun 20, 2024 · 17 comments
Open
Labels
Bug Something isn't working DSCParser Issues related to DSCParser

Comments

@ChrisFisherAllianceIT
Copy link

Description of the issue

When trying to create any type of report from an exported configuration. I receive the following error messages and it never completes. I have had this issue for a while now and I can confirm it was present in the last and current versions of the module. I just updated to version 1.24.619.1. Then I ran a new export and then tried to create a report from it. I even let it run for 4 days on the previous release where it eventually consumed all of my physical memory and 60GB of swap space before I gave up and killed the process.

image

Microsoft 365 DSC Version

Master / 1.24.619.1

Which workloads are affected

other

The DSC configuration

New-M365DSCReportFromConfiguration -Type HTML -ConfigurationPath "c:/path/config.ps1" -outputpath "c:/path/file.html"

New-M365DSCReportFromConfiguration -Type JSON -ConfigurationPath "c:/path/config.ps1" -outputpath "c:/path/file.json"

Verbose logs showing the problem

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

Environment Information + PowerShell Version

Name                           Value
----                           -----
PSVersion                      5.1.22621.3672
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.22621.3672
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
@andikrueger andikrueger added Bug Something isn't working DSCParser Issues related to DSCParser labels Jun 20, 2024
@Mohit-Shivhare
Copy link

Mohit-Shivhare commented Jun 25, 2024

I am also running similar commands to create reports from DSC config and getting below error.
I updated Microsoft365DSC module and dependencies too. The current version is - 1.24.619.1.

Parsed content was null.
At C:\Users\mshivhar\Documents\WindowsPowerShell\Modules\Microsoft365DSC\1.24.619.1\Modules\M365DSCReport.psm1:636 char:9

  •     throw "Parsed content was null."
    
  •     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    
    • CategoryInfo : OperationStopped: (Parsed content was null.:String) [], RuntimeException
    • FullyQualifiedErrorId : Parsed content was null.

@ChrisFisherAllianceIT
Copy link
Author

This issue is still present after updating to the latest release 1.24.626.1

@AlexDiNicola
Copy link

AlexDiNicola commented Jul 2, 2024

I have a similar error with Microsoft365DSC version 1.24.626.1 and DSCParser version 2.0.0.5.
The error is the following:

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:457 char:9
+         $resourceInstanceName = $resource.CommandElements[1].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

And I saw that there are 3 lines where there are the same error (470, 456, 457):

Cannot index into a null array.                                                                                         At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:**470** char:35                      + ... foreach ($keyValuePair in $resource.CommandElements[2].KeyValuePairs)                                             +                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                  + CategoryInfo          : InvalidOperation: (:) [], RuntimeException                                                    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:**456** char:9
+         $resourceType         = $resource.CommandElements[0].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.5\Modules\DSCParser.psm1:**457** char:9
+         $resourceInstanceName = $resource.CommandElements[1].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

I have this error since the update to the version 2.0.0.5 of DSCParser. With the 2.0.0.4 version of DSCParser and the version 1.24.522.1 of M365DSC, I had some error but I did not have a null html output at the end of the New-M365DSCReportFromConfiguration

@ricmestre
Copy link
Contributor

A fix for something unrelated was added to DSCParser 2.0.0.5 which now causes this problem, the workaround while that is not fixed is to just add a comment at the very first line of the blueprint as per below:

# This is the first line of my blueprint
Configuration ...

@ChrisFisherAllianceIT
Copy link
Author

This work around didn't fix the issue. Some where it's not sending over or creating a useable $associatedCIMProperty.CIMType

@HennepinCrawler
Copy link

Same error, I swear this product is like a house of cards.

@FabienTschanz
Copy link
Contributor

@Mohit-Shivhare Your issue should be fixed by #4867, that was reported outside of this issue.
@ChrisFisherAllianceIT The type problem comes from Microsoft365DSC being unable to temporarily instantiate the CIM type, which requires administrative privileges. Please run the report creation from an administrative PowerShell session and check if the error is still present.
@AlexDiNicola Can you provide a configuration for your issue and the version?

@ChrisFisherAllianceIT
Copy link
Author

ChrisFisherAllianceIT commented Jul 15, 2024

I have been running it in an Administrative Terminal which is where the issue first appeared. I have tried running it in an Administrative PowerShell session, I have tried different machines. The error is the same regardless of where or how I run it.

@FabienTschanz
Copy link
Contributor

@ChrisFisherAllianceIT Can you provide a minimal failing configuration so that I can have a look at it? What's the output of Get-Module Microsoft365DSC -ListAvailable?

@ChrisFisherAllianceIT
Copy link
Author

ChrisFisherAllianceIT commented Jul 15, 2024

Unfortunately, I can't provide a config at this time, but I've had this issue no matter what tenant I run this against.

ModuleType Version Name ExportedCommands


Manifest 1.24.710.3 Microsoft365DSC {Assert-M365DSCBlueprint, Compare-M365DSCConfigurations, C...

@FabienTschanz
Copy link
Contributor

FabienTschanz commented Jul 15, 2024

I do have an idea. Maybe the size of the configuration you can send to the DSC provider is too small.
In the registry, can you set the DWORD property maxEnvelopeSize under HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\WSMAN\Client and set its value to 8192? Afterwards, check that the configuration was applied successfully with Get-Item -Path WSMan:\localhost\MaxEnvelopeSizeKb, and then try it again.

Edit: If that doesn't work, can you export the contents of $Error after running the command in a fresh PowerShell session?

@ChrisFisherAllianceIT
Copy link
Author

ChrisFisherAllianceIT commented Jul 15, 2024

So that's interesting. There seem to be two issues that are missing from the installation instructions.

  1. WinRM wasn't enabled on my device.
  2. The Envelope size wasn't set.

Once I enabled WinRM and set the envelope size it fixed that error. Now I'm seeing a "Cannot index into a null array" for a few things but at least it's progressing

@FabienTschanz
Copy link
Contributor

FabienTschanz commented Jul 16, 2024

<Ignore comment please, didn't read carefully enough...>

@Numb3rten
Copy link

So that's interesting. There seem to be two issues that are missing from the installation instructions.

  1. WinRM wasn't enabled on my device.
  2. The Envelope size wasn't set.

Once I enabled WinRM and set the envelope size it fixed that error. Now I'm seeing a "Cannot index into a null array" for a few things but at least it's progressing

We have the same issue with error "Cannot index into a null array", with info
"C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:513"
"C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:514"
"C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:527"

these are the lines in the DSCParser for the ressources:
$resourceType = $resource.CommandElements[0].Value
$resourceInstanceName = $resource.CommandElements[1].Value
foreach ($keyValuePair in $resource.CommandElements[2].KeyValuePairs)

Do you have any idea, what could resolve this problem?

@FabienTschanz
Copy link
Contributor

@Numb3rten and @ChrisFisherAllianceIT if possible, can you provide any sample configuration that throws the error and if possible an export of the $Error variable? Then we can have a look at the callstack and determine where the error occurred.

@ricmestre
Copy link
Contributor

Most likely they have the same problem as myself, somewhere in the blueprint there's a string with configuration inside along with the Configuration initial line and the parser just can't cope with it.

As workaround for now just add an additional initial line as comment like this:

# Workaround
Configuration Example
{
...
}

@Numb3rten
Copy link

Numb3rten commented Jul 17, 2024

@Numb3rten and @ChrisFisherAllianceIT if possible, can you provide any sample configuration that throws the error and if possible an export of the $Error variable? Then we can have a look at the callstack and determine where the error occurred.

Sure:

Configuration MasterConfig
{
    param ()

    $OrganizationName = $ConfigurationData.NonNodeData.OrganizationName

    Import-DscResource -ModuleName 'Microsoft365DSC'

    Node localhost
    {
        
        AADAuthorizationPolicy c21ad7d9-4cef-4baf-81c6-2522c9cc482f
        {
            AllowedToSignUpEmailBasedSubscriptions                  = $False;
            AllowedToUseSSPR                                        = $True;
            AllowEmailVerifiedUsersToJoinOrganization               = $False;
            AllowInvitesFrom                                        = "adminsAndGuestInviters";
            BlockMsolPowerShell                                     = $True;
            ApplicationId                                           = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint                                   = $ConfigurationData.NonNodeData.CertificateThumbprint;
            TenantId                                                = $ConfigurationData.NonNodeData.TenantId;
            DefaultUserRoleAllowedToCreateApps                      = $False;
            DefaultUserRoleAllowedToCreateSecurityGroups            = $False;
            DefaultUserRoleAllowedToReadOtherUsers                  = $True;
            DefaultUserRoleAllowedToCreateTenants                   = $False;
            DefaultUserRoleAllowedToReadBitlockerKeysForOwnedDevice = $True;
            Description                                             = "Used to manage authorization related settings across the company.";
            DisplayName                                             = "Authorization Policy";
            Ensure                                                  = "Present";
            GuestUserRole                                           = "Guest";
            IsSingleInstance                                        = "Yes";
        }
        AADSecurityDefaults 501e1ed1-74b8-48f9-878b-d4ee0271d94c
        {
            ApplicationId             = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint     = $ConfigurationData.NonNodeData.CertificateThumbprint;
            TenantId                  = $ConfigurationData.NonNodeData.TenantId;
            DisplayName          = "Security Defaults";
            Description          = "Security defaults is a set of basic identity security mechanisms recommended by Microsoft. When enabled, these recommendations will be automatically enforced in your organization. Administrators and users will be better protected from common identity related attacks.";
            IsEnabled            = $False;
            IsSingleInstance     = "Yes";
        }
        AADTenantDetails bbeb241a-8c20-483d-918a-af38bf27914b
        {
            ApplicationId             = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint     = $ConfigurationData.NonNodeData.CertificateThumbprint;
            TenantId                  = $ConfigurationData.NonNodeData.TenantId;
            IsSingleInstance                     = "Yes";
            MarketingNotificationEmails          = @();
            SecurityComplianceNotificationMails  = @();
            SecurityComplianceNotificationPhones = @();
            TechnicalNotificationMails           = @($ConfigurationData.NonNodeData.TechnicalNotificationMails);
        }
        AADGroup 43f13936-21ab-4cbd-9d78-2ffaf96eb1bf
        {
            ApplicationId         = $ConfigurationData.NonNodeData.ApplicationId;
            CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
            DisplayName           = "SEC-M-ROL-ConditionalAccessEmergencyExcluded";
            Ensure                = "Present";
            GroupTypes            = @();
            MailEnabled           = $False;
            MailNickname          = "72bafaba-3";
            MemberOf              = @();
            Members               = $ConfigurationData.NonNodeData.ConditionalAccessEmergencyExcluded;
            Owners                = @();
            SecurityEnabled       = $True;
            TenantId              = $ConfigurationData.NonNodeData.TenantId;
        }
        #New Conditional Access Policy
        AADConditionalAccessPolicy "AADConditionalAccessPolicy-103 - Admin protection - AADP2 All apps: Block access For internal admins When any sign-in risk is detected"
        {
            ApplicationEnforcedRestrictionsIsEnabled = $False;
            ApplicationId                            = $ConfigurationData.NonNodeData.ApplicationId;
            BuiltInControls                          = @("block");
            CertificateThumbprint                    = $ConfigurationData.NonNodeData.CertificateThumbprint;
            ClientAppTypes                           = @("browser","mobileAppsAndDesktopClients");
            CloudAppSecurityIsEnabled                = $False;
            CloudAppSecurityType                     = "";
            CustomAuthenticationFactors              = @();
            DeviceFilterRule                         = "";
            DisplayName                              = "103 - Admin protection - AADP2 All apps: Block access For internal admins When any sign-in risk is detected";
            Ensure                                   = "Present";
            ExcludeApplications                      = @();
            ExcludeExternalTenantsMembers            = @();
            ExcludeGroups                            = @("SEC-M-ROL-ConditionalAccessEmergencyExcluded");
            ExcludeLocations                         = @();
            ExcludePlatforms                         = @();
            ExcludeRoles                             = @();
            ExcludeUsers                             = @();
            GrantControlOperator                     = "OR";
            Id                                       = "0286b6a1-3898-4f83-8de9-f431c02d46d3";
            IncludeApplications                      = @("All");
            IncludeExternalTenantsMembers            = @();
            IncludeGroups                            = @("SEC-M-ROL-ConditionalAccessAllAdmins");
            IncludeLocations                         = @();
            IncludePlatforms                         = @();
            IncludeRoles                             = @("Application Administrator","Application Developer","Attack Payload Author","Attack Simulation Administrator","Attribute Assignment Administrator","Attribute Assignment Reader","Attribute Definition Administrator","Attribute Definition Reader","Authentication Administrator","Authentication Policy Administrator","Azure DevOps Administrator","Azure Information Protection Administrator","Azure AD Joined Device Local Administrator","B2C IEF Policy Administrator","B2C IEF Keyset Administrator","Billing Administrator","Cloud App Security Administrator","Cloud Application Administrator","Cloud Device Administrator","Compliance Administrator","Compliance Data Administrator","Conditional Access Administrator","Customer LockBox Access Approver","Desktop Analytics Administrator","Directory Readers","Directory Synchronization Accounts","Directory Writers","Domain Name Administrator","Edge Administrator","Exchange Administrator","Dynamics 365 Administrator","Exchange Recipient Administrator","External ID User Flow Administrator","External ID User Flow Attribute Administrator","External Identity Provider Administrator","Global Administrator","Global Reader","Groups Administrator","Guest Inviter","Helpdesk Administrator","Hybrid Identity Administrator","Identity Governance Administrator","Insights Administrator","Insights Business Leader","Intune Administrator","Kaizala Administrator","Knowledge Administrator","Knowledge Manager","License Administrator","Message Center Privacy Reader","Message Center Reader","Network Administrator","Office Apps Administrator","Password Administrator","Fabric Administrator","Power Platform Administrator","Printer Administrator","Privileged Authentication Administrator","Printer Technician","Privileged Role Administrator","Search Administrator","Reports Reader","Search Editor","Security Administrator","Security Operator","Security Reader","Service Support Administrator","SharePoint Administrator","Skype for Business Administrator","Teams Administrator","Teams Communications Administrator","Teams Communications Support Engineer","Teams Communications Support Specialist","Teams Devices Administrator","Usage Summary Reports Reader","User Administrator","Windows 365 Administrator","Windows Update Deployment Administrator");
            IncludeUserActions                       = @();
            IncludeUsers                             = @();
            PersistentBrowserIsEnabled               = $False;
            PersistentBrowserMode                    = "";
            SignInFrequencyIsEnabled                 = $False;
            SignInFrequencyType                      = "";
            SignInRiskLevels                         = @("high","medium","low");
            State                                    = $ConfigurationData.NonNodeData.State103;
            TenantId                                 = $ConfigurationData.NonNodeData.TenantId;
            UserRiskLevels                           = @();
        }

This is a snipped of the bluepint and this is part of the $error:

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden. 
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:527 Zeichen:35
+ ... foreach ($keyValuePair in $resource.CommandElements[2].KeyValuePairs)  
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~       
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException                                                                                                  
+ FullyQualifiedErrorId : NullArray       

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:514 Zeichen:9
+         $resourceInstanceName = $resource.CommandElements[1].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:513 Zeichen:9
+         $resourceType         = $resource.CommandElements[0].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:527 Zeichen:35
+ ... foreach ($keyValuePair in $resource.CommandElements[2].KeyValuePairs)
+                               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:514 Zeichen:9
+         $resourceInstanceName = $resource.CommandElements[1].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

Es ist nicht möglich, einen Index auf ein NULL-Array anzuwenden.
In C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.7\Modules\DSCParser.psm1:513 Zeichen:9
+         $resourceType         = $resource.CommandElements[0].Value
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray

I hope it helps.

Most likely they have the same problem as myself, somewhere in the blueprint there's a string with configuration inside along with the Configuration initial line and the parser just can't cope with it.

As workaround for now just add an additional initial line as comment like this:

# Workaround
Configuration Example
{
...
}

I tried this, but no success.

Thank you very much

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working DSCParser Issues related to DSCParser
Projects
None yet
Development

No branches or pull requests

8 participants