Microsoft365DSC
Microsoft365DSC copied to clipboard
Join-M365DSCConfiguration throws Cannot index into a null array
Description of the issue
When using Join-M365DSCConfiguration to join two separate config files in the same directory the "Cannot index into a null array" error gets thrown.
Microsoft 365 DSC Version
1.25.430.1
Which workloads are affected
other
The DSC configuration
Configuration AADAdminAccounts
{
param
(
[Parameter(Mandatory = $true)]
[string] $ApplicationId,
[Parameter(Mandatory = $true)]
[string] $TenantId,
[Parameter(Mandatory = $true)]
[string] $CertificateThumbprint
)
Import-DscResource -ModuleName Microsoft365DSC -ModuleVersion '1.25.430.1'
Node localhost
{
AADUser Admin1
{
UserPrincipalName = "[email protected]"
Roles = @("Global Administrator")
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
AADUser Admin2
{
UserPrincipalName = "[email protected]"
Roles = @("Global Administrator")
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Configuration AADEmergencyAccounts
{
param
(
[Parameter(Mandatory = $true)]
[string] $ApplicationId,
[Parameter(Mandatory = $true)]
[string] $TenantId,
[Parameter(Mandatory = $true)]
[string] $CertificateThumbprint
)
Import-DscResource -ModuleName Microsoft365DSC -ModuleVersion '1.25.430.1'
Node localhost
{
AADUser Emergency1
{
UserPrincipalName = "[email protected]"
DisplayName = "Emergency Account 1"
Roles = @("Global Administrator")
Password = (ConvertTo-SecureString "12345" -AsPlainText -Force)
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
AADUser Emergency2
{
UserPrincipalName = "[email protected]"
DisplayName = "Emergency Account 2"
Roles = @("Global Administrator")
Password = (ConvertTo-SecureString "12345" -AsPlainText -Force)
Ensure = "Present"
ApplicationId = $ApplicationId
TenantId = $TenantId
CertificateThumbprint = $CertificateThumbprint
}
}
}
Verbose logs showing the problem
Cannot index into a null array.
At C:\Program Files\WindowsPowerShell\Modules\DSCParser\2.0.0.14\Modules\DSCParser.psm1:539 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.14\Modules\DSCParser.psm1:540 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.14\Modules\DSCParser.psm1:553 char:35
+ ... foreach ($keyValuePair in $resource.CommandElements[2].KeyValuePairs)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : NullArray
Environment Information + PowerShell Version
OsName : Microsoft Windows 10 Pro
OsOperatingSystemSKU : 48
OsArchitecture : 64-bit
WindowsVersion : 2009
WindowsBuildLabEx : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage : en-US
OsMuiLanguages : {en-US, hu-HU}
Key : PSVersion
Value : 5.1.19041.5737
Name : PSVersion
Key : PSEdition
Value : Desktop
Name : PSEdition
Key : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name : PSCompatibleVersions
Key : BuildVersion
Value : 10.0.19041.5737
Name : BuildVersion
Key : CLRVersion
Value : 4.0.30319.42000
Name : CLRVersion
Key : WSManStackVersion
Value : 3.0
Name : WSManStackVersion
Key : PSRemotingProtocolVersion
Value : 2.3
Name : PSRemotingProtocolVersion
Key : SerializationVersion
Value : 1.1.0.1
Name : SerializationVersion
It looks like that you have an older version of M365DSC installed. Please update it using Update-M365DSCModule and try again.
Will close the issue. If it still happens, reopen the issue.