Microsoft365DSC icon indicating copy to clipboard operation
Microsoft365DSC copied to clipboard

New-M365DSCDeltaReport hangs when module version not present

Open Kikaider opened this issue 5 years ago • 8 comments

Details of the scenario you tried and the problem that is occurring

When executing New-M365DSCDeltaReport the cmdlet never finished. No errors generated.

I was running M365DSC v1.21.428.1 on my workstation and also in my Azure Runbook, but the source config file I was comparing to was generated with M365DSC v1.21.421.2.

I no longer had 421 on my workstation, as I routinely wipe the M365DSC modules and dependencies when upgrading to a new version. My Azure Runbook was new and used the latest version of M365DSC module at the time (i.e. 428).

$path = "E:\M365DSC\roblab\src" $date = $(Get-Date -f yyyy-MMM-dd-HHMMtt) New-M365DSCDeltaReport -Source "$path\roblab-SPOSharingSettingsA.ps1" -Destination "$path\roblab-SPOSharingSettingsB.ps1" -OutputPath "$path\DeltaDeltaDelta_$date.HTML"

I installed 421 side-by-side with 428 and the New-M365DSCDeltaReport cmdlet worked fine.

Verbose logs showing the problem

N/A

Suggested solution to the issue

Have the New-M365DSCDeltaReport cmdlet fail and generate an error when it cannot find/load the required Microsoft365DSC module version.

or

If loading the module is not needed for New-M365DSCDeltaReport to work, simply ignore the difference in module versions or issue a PowerShell warning message.

The DSC configuration that is used to reproduce the issue (as detailed as possible)

roblab-SPOSharingSettingsA.ps1:

Generated with Microsoft365DSC version 1.21.421.2

For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC

Configuration RobLab-SPOSharingSettings-Config { $OrganizationName = $ConfigurationData.NonNodeData.OrganizationName Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.21.421.2'

Node localhost
{
    SPOSharingSettings 923f380a-490e-4979-b7db-3af369fdf0c4
    {
        ApplicationId                              = $ConfigurationData.NonNodeData.ApplicationId;
        BccExternalSharingInvitations              = $False;
        CertificateThumbprint                      = $ConfigurationData.NonNodeData.CertificateThumbprint;
        DefaultLinkPermission                      = "Edit";
        DefaultSharingLinkType                     = "AnonymousAccess";
        EnableGuestSignInAcceleration              = $False;
        FileAnonymousLinkType                      = "Edit";
        FolderAnonymousLinkType                    = "Edit";
        IsSingleInstance                           = "Yes";
        NotifyOwnersWhenItemsReshared              = $True;
        PreventExternalUsersFromResharing          = $False;
        ProvisionSharedWithEveryoneFolder          = $False;
        RequireAcceptingAccountMatchInvitedAccount = $False;
        SharingCapability                          = "ExternalUserAndGuestSharing";
        SharingDomainRestrictionMode               = "None";
        ShowAllUsersClaim                          = $False;
        ShowEveryoneClaim                          = $False;
        ShowEveryoneExceptExternalUsersClaim       = $True;
        ShowPeoplePickerSuggestionsForGuestUsers   = $False;
        TenantId                                   = $ConfigurationData.NonNodeData.TenantId;
    }
}

} RobLab-SPOSharingSettings-Config -ConfigurationData .\ConfigurationData.psd1

roblab-SPOSharingSettingsB.ps1:

Generated with Microsoft365DSC version 1.21.428.1

For additional information on how to use Microsoft365DSC, please visit https://aka.ms/M365DSC

Configuration RobLab-SPOSharingSettings-Config { $OrganizationName = $ConfigurationData.NonNodeData.OrganizationName Import-DscResource -ModuleName 'Microsoft365DSC' -ModuleVersion '1.21.428.1'

Node localhost
{
    SPOSharingSettings 923f380a-490e-4979-b7db-3af369fdf0c4
    {
        ApplicationId                              = $ConfigurationData.NonNodeData.ApplicationId;
        BccExternalSharingInvitations              = $False;
        CertificateThumbprint                      = $ConfigurationData.NonNodeData.CertificateThumbprint;
        DefaultLinkPermission                      = "Edit";
        DefaultSharingLinkType                     = "AnonymousAccess";
        EnableGuestSignInAcceleration              = $False;
        FileAnonymousLinkType                      = "Edit";
        FolderAnonymousLinkType                    = "Edit";
        IsSingleInstance                           = "Yes";
        NotifyOwnersWhenItemsReshared              = $True;
        PreventExternalUsersFromResharing          = $False;
        ProvisionSharedWithEveryoneFolder          = $False;
        RequireAcceptingAccountMatchInvitedAccount = $False;
        SharingCapability                          = "ExternalUserAndGuestSharing";
        SharingDomainRestrictionMode               = "None";
        ShowAllUsersClaim                          = $False;
        ShowEveryoneClaim                          = $False;
        ShowEveryoneExceptExternalUsersClaim       = $True;
        ShowPeoplePickerSuggestionsForGuestUsers   = $False;
        TenantId                                   = $ConfigurationData.NonNodeData.TenantId;
    }
}

} RobLab-SPOSharingSettings-Config -ConfigurationData .\ConfigurationData.psd1

The operating system the target node is running

N/A

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

1.21.428.1

Kikaider avatar Apr 30 '21 01:04 Kikaider

In order for a file to be parseable, it needs to be compileable. If you execute the .ps1 and it gives error, then the parsing will not work. If the version specified is not installed on the machine, the file would never compile and therefore never be able to be parsed. Hope that helps

NikCharlebois avatar Apr 30 '21 12:04 NikCharlebois

New-M365DSCDeltaReport dives into Compare-M365DSCConfigurations which dives into ConvertTo-DSCObject, but I don't see where the compilation check is done.

Regardless, (the above is more for my own edification) can the New-M365DSCDeltaReport be made to fail or timeout in this scenario?

My particular scenario is I have an Azure Runbook that checks for drift. I have not yet found a way to load multiple versions of modules into the Automation Account, but I will continue to research this. The Runbook never completes and must be manually stopped (well, maybe not never, but it runs longer than I am willing to wait, which is hours and hours).

My workaround is that before updating the Automation Account PowerShell modules, I will ensure there is no drift and update the gold standard configuration files. I don't like this because is updates the modification date and commit record for the configuration files.

Kikaider avatar Apr 30 '21 15:04 Kikaider

I exported 2 configurations last week and removed and reinstalled the M365DSC module and the New-M365DSCDeltaReport never completes.

hmank avatar May 03 '21 13:05 hmank

There are no compilation checks being one as part of the command. What I meant was that as a separate test you can try compiling the config and see if it compiles without any errors. If the parsing operation (called by New-M365DSCDeltaReport) hangs, it is related to a version conflict in 90% of the case. You need to make sure that the version referenced in the exported file is the same you have installed on your machine.

NikCharlebois avatar May 03 '21 13:05 NikCharlebois

Thank you Nik, modified the files to include the current version of the installed module and the delta report completed in seconds.

hmank avatar May 03 '21 13:05 hmank

Glad to hear....and yeah that is confusing and something we have on the backlog to look at and improve with DSCParser. Thanks

NikCharlebois avatar May 03 '21 13:05 NikCharlebois

@Kikaider keep me posted

NikCharlebois avatar May 03 '21 13:05 NikCharlebois

I was able to update my Runbook modules to match and all works well now.

Kikaider avatar May 05 '21 14:05 Kikaider