microsoft / Microsoft365DSC

Manages, configures, extracts and monitors Microsoft 365 tenant configurations
https://aka.ms/M365DSC
MIT License
1.64k stars 504 forks source link

InvalidOperation: Cannot index into a null array. #5043

Open Mazhub551 opened 2 months ago

Mazhub551 commented 2 months ago

Description of the issue

When I am trying to export the report from DSC configuration I am getting the below error. InvalidOperation: Cannot index into a null array. image

The module and all its dependencies are running on latest version. image

The export to the excel file fails to complete and abruptly closes without exporting the full report.

Microsoft 365 DSC Version

1.24.828.1

Which workloads are affected

Azure Active Directory (Entra ID)

The DSC configuration

Export-M365DSCConfiguration -Components @("AADActivityBasedTimeoutPolicy", "AADAdministrativeUnit", "AADApplication", "AADAttributeSet", "AADAuthenticationContextClassReference", "AADAuthenticationFlowPolicy", "AADAuthenticationMethodPolicy", "AADAuthenticationMethodPolicyAuthenticator", "AADAuthenticationMethodPolicyEmail", "AADAuthenticationMethodPolicyFido2", "AADAuthenticationMethodPolicySms", "AADAuthenticationMethodPolicySoftware", "AADAuthenticationMethodPolicyTemporary", "AADAuthenticationMethodPolicyVoice", "AADAuthenticationMethodPolicyX509", "AADAuthenticationStrengthPolicy", "AADAuthorizationPolicy", "AADConditionalAccessPolicy", "AADCrossTenantAccessPolicy", "AADCrossTenantAccessPolicyConfigurationDefault", "AADCrossTenantAccessPolicyConfigurationPartner", "AADEntitlementManagementAccessPackage", "AADEntitlementManagementAccessPackageAssignmentPolicy", "AADEntitlementManagementAccessPackageCatalog", "AADEntitlementManagementAccessPackageCatalogResource", "AADEntitlementManagementConnectedOrganization", "AADEntitlementManagementRoleAssignment", "AADExternalIdentityPolicy", "AADGroup", "AADGroupLifecyclePolicy", "AADGroupsNamingPolicy", "AADGroupsSettings", "AADNamedLocationPolicy", "AADRoleDefinition", "AADRoleEligibilityScheduleRequest", "AADRoleSetting", "AADSecurityDefaults", "AADServicePrincipal", "AADSocialIdentityProvider", "AADTenantDetails", "AADTokenLifetimePolicy", "AADUser") -FileName "NEC_DSC_Extract_10_09_2024.ps1" -Path "C:\Temp\M365DSC\"  -Credential $Credential

Verbose logs showing the problem

[2024/09/11 03:55:42]
{InvalidOperation}
System.Management.Automation.RuntimeException: You cannot call a method on a null-valued expression.
   at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception)
   at lambda_method(Closure , Object[] , StrongBox`1[] , InterpretedFrame )
"Error during conversion to Excel:"
at New-M365DSCConfigurationToExcel, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.828.1\Modules\M365DSCReport.psm1: line 496
at New-M365DSCReportFromConfiguration, C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.828.1\Modules\M365DSCReport.psm1: line 623
at <ScriptBlock>, <No file>: line 1

Environment Information + PowerShell Version

No response

FabienTschanz commented 2 months ago

First, can you please update the Microsoft365DSC module using Install-Module Microsoft365DSC -Force and then Update-M365DSCModule, both running in an elevated Windows PowerShell session?

FabienTschanz commented 3 weeks ago

@Mazhub551 Please give us an update on the situation or close the issue if it is working for you now.

BPJac commented 1 week ago

I'm getting this same error. Running this command: New-M365DSCReportFromConfiguration -type Excel -ConfigurationPath "C:\Users**s\Output*SecCom.ps1" -OutputPath C:\Users\\output**SecCom.xlsx The excel report does open, but only populates one of the components. (SCComplianceSearch) The original config file was created using this command and the PS1 does contain a lot of data. Export-M365DSCConfiguration -Components @("SCAuditConfigurationPolicy", "SCAutoSensitivityLabelPolicy", "SCAutoSensitivityLabelRule", "SCCaseHoldPolicy", "SCCaseHoldRule", "SCComplianceCase", "SCComplianceSearch", "SCComplianceSearchAction", "SCComplianceTag", "SCDeviceConditionalAccessPolicy", "SCDeviceConfigurationPolicy", "SCDLPCompliancePolicy", "SCDLPComplianceRule", "SCFilePlanPropertyAuthority", "SCFilePlanPropertyCategory", "SCFilePlanPropertyCitation", "SCFilePlanPropertyDepartment", "SCFilePlanPropertyReferenceId", "SCFilePlanPropertySubCategory", "SCLabelPolicy", "SCProtectionAlert", "SCRetentionCompliancePolicy", "SCRetentionComplianceRule", "SCRetentionEventType", "SCRoleGroup", "SCRoleGroupMember", "SCSecurityFilter", "SCSensitivityLabel", "SCSupervisoryReviewPolicy", "SCSupervisoryReviewRule") -Credential $Credential -Filename **SecCom.ps1

FabienTschanz commented 1 week ago

@BPJac Are you on the latest version of Microsoft365DSC? Get-Module Microsoft365DSC -ListAvailable

BPJac commented 6 days ago

@FabienTschanz yes I believe so, and also Powershell 7.4.6 PS C:\Users****> Get-Module Microsoft365DSC -ListAvailable | fl

Name : Microsoft365DSC Path : C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.24.1120.1\Microsoft365DSC.psd1 Description : This DSC module is used to configure and monitor Microsoft tenants, including SharePoint Online, Exchange, Teams, etc. ModuleType : Manifest Version : 1.24.1120.1 PreRelease : NestedModules : {M365DSCAgent, M365DSCDocGenerator, M365DSCErrorHandler, M365DSCLogEngine…} ExportedFunctions : {Test-M365DSCAgent, Set-M365DSCAgentCertificateConfiguration, Get-ResourceExampleAsMarkdown, New-DscMofResourceWikiPage…} ExportedCmdlets : {Assert-M365DSCBlueprint, Compare-M365DSCConfigurations, Confirm-M365DSCDependencies, Export-M365DSCConfiguration…} ExportedVariables : ExportedAliases :

FabienTschanz commented 6 days ago

Is there any other output mentioned after the error? What happens if you run the command in an elevated PowerShell window? How does it look like if you're using Windows PowerShell 5.1?