microsoft / Microsoft365DSC

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

Compare-M365DSCConfigurations not recognized #1966

Closed myacaman closed 2 years ago

myacaman commented 2 years ago

Hello all, we are trying to run the Compare-M365DSCConfigurations command and we are getting that it is not recognized. We have installed the DSC module and updated it several times but it does not seem to recognize this command. Please see the error message below. Can anyone provide some guidance onto what is going on? We are able to successfully run the compare command in our test tenant instance. Thank you in advance for your help.


Compare-M365DSCConfigurations : The term 'Compare-M365DSCConfigurations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:28

Version of the DSC module that was used ('dev' if using current dev branch)

andikrueger commented 2 years ago

could you share the output of the following command:

get-module microsoft365dsc -listavailable
myacaman commented 2 years ago

We are able to run the command with version 1.22.105.1. The second we update to 1.22.511.1 or 1.22.518.1 we get the error message that it cannot be recognized.

Output ModuleType Version Name ExportedCommands


Manifest 1.22.518.1 Microsoft365DSC {Assert-M365DSCBlueprint, Assert-M365DSCTemplate, Compare-M365DSCConfigurations, Confirm-M365DSCDependencies...

Manifest 1.22.511.1 Microsoft365DSC {Assert-M365DSCBlueprint, Assert-M365DSCTemplate, Compare-M365DSCConfigurations, Confirm-M365DSCDependencies...

Manifest 1.22.105.1 Microsoft365DSC {Assert-M365DSCBlueprint, Assert-M365DSCTemplate, Compare-M365DSCConfigurations, Confirm-M365DSCDependencies...

andikrueger commented 2 years ago

Could you run the following commands

Update-Module Microsoft365DSC Update-M365DSCDependencies Uninstall-M365DSCOutdatedDependencies

This should remove all old versions of the module and outdated dependencies too. There will be an error during the uninstall. Please close the powershell session and rerun the third command afterwards.

myacaman commented 2 years ago

I ran the commands as you said and indeed got some errors. Then I rerun the uninstall as you suggested and I get the errors below.

PS C:\Windows\system32> Uninstall-M365DSCOutdatedDependencies Uninstalling Microsoft.Graph.Authentication version {1.9.5} PackageManagement\Uninstall-Package : The module 'Microsoft.Graph.Authentication' of version '1.9.5' in module base folder 'C:\ProgramFiles\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\1.9.5' cannot be uninstalled, because one or more other modules 'Microsoft.Graph.Applications,Microsoft.Graph.DeviceManagement,Microsoft.Graph.DeviceManagement.Administration,Microsoft.Graph.DeviceManagement.Enrolment,Microsoft.Graph.Devices.CorporateManagement,Microsoft.Gra ph.Groups,Microsoft.Graph.Identity.DirectoryManagement,Microsoft.Graph.Identity.Governance,Microsoft.Graph.Identity.SignIns,Microsoft.Graph.Planner,Microsoft.Graph.Teams,Microsoft.Graph.Users' are dependent on this module. Uninstall the modules that depend on this module before uninstalling module 'Microsoft.Graph.Authentication'.

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:12733 char:21

Uninstalling Microsoft.Graph.Authentication version {1.9.1} PackageManagement\Uninstall-Package : The module 'Microsoft.Graph.Authentication' of version '1.9.1' in module base folder 'C:\ProgramFiles\WindowsPowerShell\Modules\Microsoft.Graph.Authentication\1.9.1' cannot be uninstalled, because one or more other modules 'Microsoft.Graph.Applications,Microsoft.Gr aph.DeviceManagement,Microsoft.Graph.DeviceManagement.Administration,Microsoft.Graph.DeviceManagement.Enrolment,Microsoft.Graph.Devices.CorporateManagement,Microsoft.Graph.Groups,Microsoft.Graph.Identity.DirectoryManagement,Microsoft.Graph.Identity.Governance,Microsoft.Graph.Identity.SignIns,Microsoft.Graph.Planner,Microsoft.Graph.Teams,Microsoft.Graph.Users' are dependent on this module. Uninstall the modules that depend on this module before uninstalling module 'Microsoft.Graph.Authentication'. At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\2.2.5\PSModule.psm1:12733 char:21

andikrueger commented 2 years ago

There was a new release a few minutes ago. This should include a fix for the error messages above.

myacaman commented 2 years ago

Thanks. I just reran the update commands as you suggested above and although we do get the newest version, 1.22.525.1 we are still getting the same error.

Compare-M365DSCConfigurations : The term 'Compare-M365DSCConfigurations' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again. At line:1 char:28

andikrueger commented 2 years ago

Could you run the following to see, if the module is loaded correctly:

Get-Module Microsoft365DSC | fl

This should show all exported functions.

myacaman commented 2 years ago

This is what we get.

Name : Microsoft365DSC Path : C:\Program Files\WindowsPowerShell\Modules\Microsoft365DSC\1.22.525.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.22.525.1 NestedModules : {M365DSCAgent, M365DSCErrorHandler, M365DSCLogEngine, M365DSCPermissions...} ExportedFunctions : {Add-M365DSCEvent, Add-M365DSCTelemetryEvent, Assert-M365DSCBlueprint, Confirm-ImportedCmdletIsAvailable...} ExportedCmdlets : ExportedVariables : ExportedAliases :

I then expand the exported functions and I get this.

Set-M365DSCAgentCertificateConfiguration Set-M365DSCAgentCertificateConfiguration Test-M365DSCAgent Test-M365DSCAgent Save-M365DSCPartialExport Save-M365DSCPartialExport Add-M365DSCEvent Add-M365DSCEvent Export-M365DSCDiagnosticData Export-M365DSCDiagnosticData New-M365DSCLogEntry New-M365DSCLogEntry Get-M365DSCCompiledPermissionList Get-M365DSCCompiledPermissionList Update-M365DSCAllowedGraphScopes Update-M365DSCAllowedGraphScopes Update-M365DSCResourcesSettingsJSON Update-M365DSCResourcesSettingsJSON New-M365DSCDeltaReport New-M365DSCDeltaReport New-M365DSCReportFromConfiguration New-M365DSCReportFromConfiguration Start-M365DSCConfigurationExtract Start-M365DSCConfigurationExtract New-M365DSCStubFiles New-M365DSCStubFiles Add-M365DSCTelemetryEvent Add-M365DSCTelemetryEvent Format-M365DSCTelemetryParameters Format-M365DSCTelemetryParameters Get-M365DSCTelemetryOption Get-M365DSCTelemetryOption Set-M365DSCTelemetryOption Set-M365DSCTelemetryOption Assert-M365DSCBlueprint Assert-M365DSCBlueprint Confirm-ImportedCmdletIsAvailable Confirm-ImportedCmdletIsAvailable Confirm-M365DSCDependencies Confirm-M365DSCDependencies Convert-M365DscHashtableToString Convert-M365DscHashtableToString ConvertTo-SPOUserProfilePropertyInstanceString ConvertTo-SPOUserProfilePropertyInstanceString Export-M365DSCConfiguration Export-M365DSCConfiguration Get-AllSPOPackages Get-AllSPOPackages Get-M365DSCAllResources Get-M365DSCAllResources Get-M365DSCAuthenticationMode Get-M365DSCAuthenticationMode Get-M365DSCComponentsForAuthenticationType Get-M365DSCComponentsForAuthenticationType Get-M365DSCExportContentForResource Get-M365DSCExportContentForResource Get-M365DSCOrganization Get-M365DSCOrganization Get-M365DSCTenantDomain Get-M365DSCTenantDomain Get-M365DSCWorkloadsListFromResourceNames Get-M365DSCWorkloadsListFromResourceNames Get-M365TenantName Get-M365TenantName Get-SPOAdministrationUrl Get-SPOAdministrationUrl Get-SPOUserProfilePropertyInstance Get-SPOUserProfilePropertyInstance Get-TeamByName Get-TeamByName Import-M365DSCDependencies Import-M365DSCDependencies Install-M365DSCDevBranch Install-M365DSCDevBranch Invoke-M365DSCCommand Invoke-M365DSCCommand New-EXOSafeAttachmentRule New-EXOSafeAttachmentRule New-EXOSafeLinksRule New-EXOSafeLinksRule New-M365DSCCmdletDocumentation New-M365DSCCmdletDocumentation New-M365DSCConnection New-M365DSCConnection New-M365DSCMissingResourcesExample New-M365DSCMissingResourcesExample Remove-EmptyValue Remove-EmptyValue Remove-NullEntriesFromHashtable Remove-NullEntriesFromHashtable Set-EXOSafeAttachmentRule Set-EXOSafeAttachmentRule Set-EXOSafeLinksRule Set-EXOSafeLinksRule Split-ArrayByParts Split-ArrayByParts Test-M365DSCDependenciesForNewVersions Test-M365DSCDependenciesForNewVersions Test-M365DSCNewVersionAvailable Test-M365DSCNewVersionAvailable Test-M365DSCParameterState Test-M365DSCParameterState Uninstall-M365DSCOutdatedDependencies Uninstall-M365DSCOutdatedDependencies Update-M365DSCDependencies Update-M365DSCDependencies Update-M365DSCExportAuthenticationResults Update-M365DSCExportAuthenticationResults Format-M365DSCString Format-M365DSCString

I dont seem to see the compare one.

andikrueger commented 2 years ago

Sorry for the inconvenience. I had a closer look into the code and the changelog. With V 1.22.126.1 (around 5 months ago) we introduced a change that did made compare-m365dscconfigurations an internal and hidden function.

Please follow this guide to compare two configurations with the latest version of M365 DSC: https://microsoft365dsc.com/user-guide/get-started/comparing-configurations/

@ykuijs any chance we can remove the function compare-m365dscconfigurations from the module manifest, as we are blocking this function to be exported within the nested module?

https://github.com/microsoft/Microsoft365DSC/blob/f84cde5d655b7710d236e8caf8d0cfdc510a72b2/Modules/Microsoft365DSC/Microsoft365DSC.psd1#L86-L88

and

https://github.com/microsoft/Microsoft365DSC/blob/0a93283cb5bba9926ea45ea3d3f3854aea9bd867/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1#L424-L431

and

https://github.com/microsoft/Microsoft365DSC/blob/0a93283cb5bba9926ea45ea3d3f3854aea9bd867/Modules/Microsoft365DSC/Modules/M365DSCReport.psm1#L1050-L1053

myacaman commented 2 years ago

@andikrueger We tried using the delta module instead, but it is not working from us because it only allows exporting the report in excel of html format. The compare module instead, allowed us to export the report as PS object so we can use it later to add additional data. is there a way we can leverage the delta report module to output a PS object? What do you recommend?

andikrueger commented 2 years ago

As a short term solution you could modify the file \modules\M365DSCReport.psm1 To export compare-m365dscconfigurations.

To do so you need to add the function to the array in lines 1050-1053.

ykuijs commented 2 years ago

@andikrueger Yes, I will remove this from the module manifest!

ykuijs commented 2 years ago

@myacaman The Compare-M365DSCConfigurations function is an internal method that is being used by other functions. That is why we made it hidden.

To understand a little better what you are trying to accomplish and to see how we can best provide this functionality: What exactly are you doing and how does this function fit into that scenario? Can you provide a little more insights/details?

ykuijs commented 2 years ago

@myacaman Not sure if you are aware, but the New-M365DSCReportFromConfiguration function is also able to export to JSON, maybe that is something you can use.