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

New-M365DSCReportFromConfiguration: en dash in EXOGroupSettings DisplayName causes DSCParser exception #5202

Open
nick-waterhouse opened this issue Oct 18, 2024 · 3 comments

Comments

@nick-waterhouse
Copy link

nick-waterhouse commented Oct 18, 2024

Description of the issue

While attempting to create a report for a configuration, I received similar exceptions to those in the verbose logs.

I was able to reduce the configuration down to the one in the DSC configuration section, where the configuration reliably caused an exception.

My script is as follows:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine

$NetConnection = Get-NetConnectionProfile
Set-NetConnectionProfile -InterfaceAlias $NetConnection.InterfaceAlias -NetworkCategory "Private"
winrm quickconfig

New-M365DSCReportFromConfiguration -type html -ConfigurationPath ..\Reports\source.psd -OutputPath ..\Reports\report.html

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine
Set-NetConnectionProfile -InterfaceAlias $NetConnection.InterfaceAlias -NetworkCategory $NetConnection.NetworkCategory

Strangely, the culprit is having the DisplayName contain an en dash, such as "Group – name" - I expect other characters, such as em dash, would behave similarly. If I replace this character with a regular minus character, or remove it completely, the report is successfully created.

I can confirm that my dependencies are up to date, and that I am running this in an elevated terminal.

Is there anything that can be done here?

Microsoft 365 DSC Version

V1.24.1016.1

Which workloads are affected

Exchange Online

The DSC configuration

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

Configuration Microsoft365TenantConfigExport-tenant.onmicrosoft.com-2024-09-17
{
    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]

    if ($null -eq $Credential)
    {
        <# Credentials #>
    }
    else
    {
        $CredsCredential = $Credential
    }

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

    Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.24.904.1'

    Node localhost
    {
        EXOGroupSettings "Test Name"
        {
            AccessType                             = "Public";
            AlwaysSubscribeMembersToCalendarEvents = $False;
            AuditLogAgeLimit                       = "90.00:00:00";
            AutoSubscribeNewMembers                = $False;
            ConnectorsEnabled                      = $True;
            Credential                             = $Credscredential;
            CustomAttribute1                       = "";
            CustomAttribute10                      = "";
            CustomAttribute11                      = "";
            CustomAttribute12                      = "";
            CustomAttribute13                      = "";
            CustomAttribute14                      = "";
            CustomAttribute15                      = "";
            CustomAttribute2                       = "";
            CustomAttribute3                       = "";
            CustomAttribute4                       = "";
            CustomAttribute5                       = "";
            CustomAttribute6                       = "";
            CustomAttribute7                       = "";
            CustomAttribute8                       = "";
            CustomAttribute9                       = "";
            DisplayName                            = "Group–name";
            EmailAddresses                         = @("SPO:SPO_076bc706-8bdf-4a49-9402-eb045b8c47e1@SPO_3e26c7b7-e5f0-44a2-b10d-c2eddac91f62","smtp:groupforanswersinvivaengagedonotdelete1823809462b81@tenant.onmicrosoft.com","smtp:groupforanswersinvivaengagedonotdelete1823809462@tenant.onmicrosoft.com","SMTP:groupforanswersinvivaengagedonotdelete1823809462@$OrganizationName");
            HiddenFromAddressListsEnabled          = $False;
            HiddenFromExchangeClientsEnabled       = $False;
            Id                                     = "groupforanswersinvivaengage_78de5c5f-5398-4387-a549-b9493af29acd";
            InformationBarrierMode                 = "Open";
            Language                               = "en-US";
            MaxReceiveSize                         = "36 MB (37,748,736 bytes)";
            MaxSendSize                            = "35 MB (36,700,160 bytes)";
            ModerationEnabled                      = $False;
            Notes                                  = "Group that stores content and metadata for Answers in Viva Engage in network 1823809. Deleting this this group will disrupt Answers in Viva Engage.";
            PrimarySmtpAddress                     = "groupforanswersinvivaengagedonotdelete1823809462@$OrganizationName";
            RequireSenderAuthenticationEnabled     = $True;
            SubscriptionEnabled                    = $False;
            TenantId                               = "tenant.onmicrosoft.com";
        }
    }
}

Microsoft365TenantConfigExport-tenant.onmicrosoft.com-2024-09-17 -ConfigurationData .\ConfigurationData.psd1 -Credential $Credential

Verbose logs showing the problem

Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.11\Modules\DSCParser.psm1:548 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.11\Modules\DSCParser.psm1:549 char:9                        
	+         $resourceInstanceName = $resource.CommandElements[1].Value                                                      
	+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                                          
	+ CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : NullArray

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

Environment Information + PowerShell Version

OsName : Microsoft Windows 11 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 22000.1.amd64fre.co_release.210604-1628
OsLanguage : en-GB
OsMuiLanguages : {en-GB, en-US}

@FabienTschanz
Copy link
Contributor

That sounds very strange, but somehow I expected something like that. The culprit here might be the fact that en dash is a Unicode character and not all Unicode characters might be available… I‘ll take a look at it if I have time.

@ricmestre
Copy link
Contributor

ricmestre commented Oct 18, 2024

@FabienTschanz This is a known issue, check out #4824

@FabienTschanz
Copy link
Contributor

Uhmm, "it works on my machine" 😓 Will dig a bit deeper.

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