Microsoft365DSC
Microsoft365DSC copied to clipboard
New-M365DSCDeltaReport: Getting `You cannot call a method on a null-valued expression` and empty report on PowerShell 7
Description of the issue
I'm trying to identify if PowerShell 7 usage in our environment will decrease the time it will take to run through our pipeline on a large set of AAD groups (over 4000).
I run the command: Export-M365DSCConfiguration -MaxProcesses 8 -Components AADGroup -Path output/exports/AAD -FileName AADGroup.ps1 -CertificateThumbprint $thumbprint -TenantId $tenantName -ApplicationId $applicationID
I get the exported groups, so then run the command: New-M365DSCDeltaReport -Verbose -Source configurations\AAD\AADGroup.ps1 -Destination output/exports/AAD/AADGroup.ps1 -Type HTML -OutputPath output/deltas/AAD/AADGroup.html
I get the following output: VERBOSE: Obtaining Delta between the source and destination configurations VERBOSE: Loading file 'configurations/AAD\AADGroup.ps1' VERBOSE: Loading file 'output/exports/AAD/AADGroup.ps1' Error: You cannot call a method on a null-valued expression. Error: You cannot call a method on a null-valued expression. Error: You cannot call a method on a null-valued expression. [I think I get one of these per group in the source file]
Microsoft 365 DSC Version
1.24.214.3
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 : en-GB
OsMuiLanguages : {en-GB, en-US}
Name Value
---- -----
PSVersion 7.4.1
PSEdition Core
GitCommitId 7.4.1
OS Microsoft Windows 10.0.22631
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Could you share some sample data and is this also the case within PS5?
This is working using PowerShell 5.
Here is the exported group sample:
# Generated with Microsoft365DSC version 1.24.214.3
# For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC
param (
)
Configuration AADGroup
{
param (
)
$OrganizationName = $ConfigurationData.NonNodeData.OrganizationName
Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.24.214.3'
Node localhost
{
AADGroup "AADGroup-REDACTED"
{
ApplicationId = $ConfigurationData.NonNodeData.ApplicationId;
CertificateThumbprint = $ConfigurationData.NonNodeData.CertificateThumbprint;
DisplayName = "REDACTED";
Ensure = "Present";
GroupTypes = @();
Id = "REDACTED";
MailEnabled = $False;
MailNickname = "REDACTED";
MemberOf = @();
Members = @();
Owners = @();
SecurityEnabled = $True;
TenantId = $OrganizationName;
}
}
}
AADGroup -ConfigurationData .\ConfigurationData.psd1
Here is the source file sample:
param (
[Parameter(Mandatory = $true)]
[string]$ApplicationID,
[Parameter(Mandatory = $true)]
[string]$CertificateThumbprint,
[Parameter(Mandatory = $true)]
[string]$TenantName,
[Parameter(Mandatory = $true)]
[string]$OutputDirectory
)
Configuration AADGroup
{
param (
)
Import-DscResource -ModuleName 'Microsoft365DSC'
Node localhost
{
AADGroup "AADGroup-REDACTED"
{
ApplicationId = $ApplicationId;
CertificateThumbprint = $CertificateThumbprint;
TenantId = $TenantName;
DisplayName = "REDACTED";
Ensure = "Present";
GroupTypes = @();
MailEnabled = $False;
MailNickname = "TCS_Alexander_House";
MemberOf = @();
SecurityEnabled = $True;
}
}
}
AADGroup -OutputPath $OutputDirectory