microsoft / Microsoft365DSC

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

New-M365DSCReportFromConfiguration: Excel report generation fails #3640

Open horgasz2023 opened 1 year ago

horgasz2023 commented 1 year ago

Description of the issue

Excel report generation fails on a newly provisioned AAD tenant. MS Excel version 2308 Build 16.0.16731.20051 64 bit.

Microsoft 365 DSC Version

1.23.830.1

Which workloads are affected

Azure Active Directory

The DSC configuration

Freshly provisioned AAD tenant with one Global Admin.

Verbose logs showing the problem

2264-M365DSC-ErrorLog.log

Environment Information + PowerShell Version

OsName               : Microsoft Windows 10 Enterprise
OsOperatingSystemSKU : EnterpriseEdition
OsArchitecture       : 64-bit
WindowsVersion       : 2009
WindowsBuildLabEx    : 19041.1.amd64fre.vb_release.191206-1406
OsLanguage           : en-US
OsMuiLanguages       : {en-US}
NikCharlebois commented 1 year ago

Can you share the redacted configuration file used (.ps1)? Thanks

horgasz2023 commented 1 year ago

@{ AllNodes = @( @{ NodeName = "localhost" PSDscAllowPlainTextPassword = $true; PSDscAllowDomainUser = $true;

region Parameters

        # Default Value Used to Ensure a Configuration Data File is Generated
        ServerNumber = "0"

    }
)
NonNodeData = @(
    @{
        # Tenant's default verified domain name
        OrganizationName = "xxxxxx.onmicrosoft.com"

        # Azure AD Application Id for Authentication
        ApplicationId = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

        # The Id or Name of the tenant to authenticate against
        TenantId = "xxxxx.onmicrosoft.com"

        # Azure AD Application Secret for Authentication
        ApplicationSecret = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

    }
)

}

horgasz2023 commented 1 year ago

FYI checked with current versions (PS 7.3.6) Update-M365DSCModule

Untrusted repository You are installing the modules from an untrusted repository. If you trust this repository, change its InstallationPolicy value by running the Set-PSRepository cmdlet. Are you sure you want to install the modules from 'PSGallery'? [Y] Yes [A] Yes to All [N] No [L] No to All [S] Suspend [?] Help (default is "N"): A Installing ExchangeOnlineManagement version {3.3.0} Installing Microsoft.Graph.Applications version {2.5.0} Installing Microsoft.Graph.Beta.DeviceManagement version {2.5.0} Installing Microsoft.Graph.Beta.Devices.CorporateManagement version {2.5.0} Installing Microsoft.Graph.Beta.DeviceManagement.Administration version {2.5.0} Installing Microsoft.Graph.Beta.DeviceManagement.Enrollment version {2.5.0} Installing Microsoft.Graph.Beta.Identity.DirectoryManagement version {2.5.0} Installing Microsoft.Graph.Beta.Identity.Governance version {2.5.0} Installing Microsoft.Graph.Beta.Identity.SignIns version {2.5.0} Installing Microsoft.Graph.Beta.Reports version {2.5.0} Installing Microsoft.Graph.Beta.Teams version {2.5.0} Installing Microsoft.Graph.DeviceManagement.Administration version {2.5.0} Installing Microsoft.Graph.Beta.DirectoryObjects version {2.5.0} Installing Microsoft.Graph.Groups version {2.5.0} Installing Microsoft.Graph.Planner version {2.5.0} Installing Microsoft.Graph.Users version {2.5.0} Installing Microsoft.Graph.Users.Actions version {2.5.0} Installing MSCloudLoginAssistant version {1.0.120} Uninstalling Microsoft365DSC Version {1.23.906.1} Uninstalling ExchangeOnlineManagement Version {3.2.0} Uninstalling ExchangeOnlineManagement Version {3.2.0} Uninstalling Microsoft.Graph.Applications Version {2.4.0} Uninstalling Microsoft.Graph.Applications Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Devices.CorporateManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Devices.CorporateManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement.Administration Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement.Administration Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement.Enrollment Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DeviceManagement.Enrollment Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.DirectoryManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.DirectoryManagement Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.Governance Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.Governance Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.SignIns Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Identity.SignIns Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Teams Version {2.4.0} Uninstalling Microsoft.Graph.Beta.Teams Version {2.4.0} Uninstalling Microsoft.Graph.DeviceManagement.Administration Version {2.4.0} Uninstalling Microsoft.Graph.DeviceManagement.Administration Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DirectoryObjects Version {2.4.0} Uninstalling Microsoft.Graph.Beta.DirectoryObjects Version {2.4.0} Uninstalling Microsoft.Graph.Groups Version {2.4.0} Uninstalling Microsoft.Graph.Groups Version {2.4.0} Uninstalling Microsoft.Graph.Planner Version {2.4.0} Uninstalling Microsoft.Graph.Planner Version {2.4.0} Uninstalling Microsoft.Graph.Users Version {2.4.0} Uninstalling Microsoft.Graph.Users Version {2.4.0} Uninstalling Microsoft.Graph.Users.Actions Version {2.4.0} Uninstalling Microsoft.Graph.Users.Actions Version {2.4.0} Checking Microsoft.Graph.Authentication Uninstalling Microsoft.Graph.Authentication version {2.4.0} Uninstalling Microsoft.Graph.Authentication version {2.4.0}

New-M365DSCReportFromConfiguration -Type 'Excel' -ConfigurationPath 'C:\m365\New\M365TenantConfig.ps1' -OutputPath 'C:\m365\new\M365DSCConfiguration_DEV.xlsx' WARNING: ConvertTo-DSCObject: "" (line 240): There is an incomplete property assignment block in the instance definition. WARNING: ConvertTo-DSCObject: "" (line 238): There is an incomplete property assignment block in the instance definition. WARNING: ConvertTo-DSCObject: "" (line 234): There is an incomplete property assignment block in the instance definition. WARNING: ConvertTo-DSCObject: "}" (line 283): Unexpected token '}' in expression or statement. WARNING: ConvertTo-DSCObject: "}" (line 7948): Unexpected token '}' in expression or statement. WARNING: ConvertTo-DSCObject: "}" (line 7949): Unexpected token '}' in expression or statement. WARNING: ConvertTo-DSCObject: "AADAuthenticationMethodPolicyAuthenticator" (line 233): Resource 'AADAuthenticationMethodPolicyAuthenticator' requires that a value of type 'String' be provided for property 'Id'.

So with this setup it generates the xls with these yellow warnings.

Get-Module Microsoft365DSC -ListAvailable | select ModuleBase, Version

ModuleBase Version


C:\Program Files\PowerShell\Modules\Microsoft365DSC\1.23.913.2 1.23.913.2

manunair-shell commented 1 year ago

I am also facing the same issue, I am running the script on the VM. Observation :

If you are running the script which is trying to export the report of the configuration data into an excel [.xlsx] file, then it will get fail because there is no Office 365 apps installed on the VM.

In the version 1.23.913.1 of Microsoft 365DSC Module, There is a command New-Object -ComObject excel.application under M365DSCReport file. This command is trying to use the exel application and write a configuration data into the excel. If excel app is not present in the machine then the New-M365DSCReportFromConfiguration command will get stuck and no output is generated.

Feedback/Suggestion : The module should check and notify the dependencies which are missing. Also it should support CSV file format to generate the report and documentation should be updated over https://microsoft365dsc.com/

@NikCharlebois @andikrueger