Azure / Azure/GuestConfiguration
New-GuestConfigurationPackage includes duplicate modules
- Dominant language
- PowerShell
- Stars
- 8
- Forks
- 13
- PR merge metrics
- No merged PRs in 30d
Description
#### Details of the scenario you tried and the problem that is occurring
It appears that if a module is used by more than one instance of a resource in a config, `New-GuestConfigurationPackage` will include two copies of the module in the package produced. For example, Microsoft.WinGet.Client was included in `Modules\Microsoft.WinGet.Client` and `Modules\Microsoft.WinGet.Client\1.11.410` in the zip.
Verbose output shows that each module is copied multiple times, once for each resource that uses it. `Copy-Item` behaves different when the destination folder already exists, which is why the module then gets included in the package twice.
Main issue this caused me is with Microsoft.WinGet.Client included twice, the package is just over 100MB unzipped so the VM assignment fails.
#### Verbose logs showing the problem
```log
>> New-GuestConfigurationPackage -Name Software -Configuration .\Software\localhost.mof -Type AuditAndSet -Version 1.9331.37777 -Verbose -Force
VERBOSE: Starting New-GuestConfigurationPackage
VERBOSE: Found resource dependency in mof with instance name 'Web-Server' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-WebServer' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Common-Http' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Default-Doc' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Dir-Browsing' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Http-Errors' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Static-Content' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Health' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Http-Logging' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Http-Tracing' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Performance' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Stat-Compression' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Security' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Filtering' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-IP-Security' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-App-Dev' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Net-Ext45' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-AppInit' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Asp-Net45' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-WebSockets' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Mgmt-Tools' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Mgmt-Console' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'Web-Scripting-Tools' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'NET-Framework-45-Features' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'NET-Framework-45-Core' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'NET-Framework-45-ASPNET' and resource name 'DSC_xWindowsFeature' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name '' and resource name 'WinGetPackage' from module 'Microsoft.WinGet.DSC' with version '1.11.410'.
VERBOSE: Found resource dependency in mof with instance name 'Microsoft Application Request Routing 3.0' and resource name 'DSC_xPackageResource' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found resource dependency in mof with instance name 'IIS URL Rewrite Module 2' and resource name 'DSC_xPackageResource' from module 'xPSDesiredStateConfiguration' with version '9.2.1'.
VERBOSE: Found 37 resource dependencies in the mof.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.DSC' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.DSC.
VERBOSE: Loading module from path 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410\Microsoft.WinGet.DSC.psm1'.
VERBOSE: The module 'Microsoft.WinGet.DSC' requires the module 'Microsoft.WinGet.Client'
VERBOSE: Searching for a module with the name 'Microsoft.WinGet.Client' and version '1.11.410'...
VERBOSE: Populating RepositorySourceLocation property for module Microsoft.WinGet.Client.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Searching for a module with the name 'xPSDesiredStateConfiguration' and version '9.2.1'...
VERBOSE: Populating RepositorySourceLocation property for module xPSDesiredStateConfiguration.
VERBOSE: Found the module dependencies: xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration xPSDesiredStateConfiguration Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client Microsoft.WinGet.DSC Microsoft.WinGet.Client xPSDesiredStateConfiguration xPSDesiredStateConfiguration
VERBOSE: Creating the package root folder at the path 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software'...
VERBOSE: Creating the package Modules folder at the path 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules'...
VERBOSE: Setting the content of the package metaconfig at the path 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Software.metaconfig.json'...
VERBOSE: Copying the compiled DSC configuration (.mof) from the path 'REDACTED\dsc\output\Software\localhost.mof' to the package path 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Software.mof'...
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.DSC\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.DSC'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\Microsoft.WinGet.Client\1.11.410' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\Microsoft.WinGet.Client'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Copying module from 'C:\Users\UserProfile\Documents\PowerShell\Modules\xPSDesiredStateConfiguration\9.2.1' to 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software\Modules\xPSDesiredStateConfiguration'
VERBOSE: Removing an existing item at the path 'REDACTED\dsc\output\Software.zip'...
VERBOSE: Compressing the generated package from the path 'C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\gcworker\temp\Software' to the package path 'REDACTED\dsc\output\Software.zip'...
```
#### Suggested solution to the issue
Would probably be best to filter the module list to just distinct modules. I've patched my local module with the below and it seems to work well.
```powershell
if ($moduleDependencies.Count -gt 0)
{
Write-Verbose -Message "Found the module dependencies: $($moduleDependencies.Name | Sort-Object | Get-Unique)"
}
$duplicateModules = @( $moduleDependencies | Group-Object -Property 'Name' )
$distinctModules = @()
foreach ($duplicateModule in $duplicateModules)
{
$uniqueVersions = @( $duplicateModule.Group.Version | Get-Unique )
if ($uniqueVersions.Count -gt 1)
{
$moduleName = $duplicateModule.Group[0].Name
throw "Cannot include more than one version of a module in one package. Detected versions $uniqueVersions of the module '$moduleName' are needed for this package."
}
$distinctModules += $duplicateModule.Group[0]
}
$moduleDependencies = $distinctModules
```
replaces
https://github.com/Azure/GuestConfiguration/blob/b2f0a087fbe9266135a4859e61214d37a4b14692/source/Public/New-GuestConfigurationPackage.ps1#L186-L202
#### The DSC configuration that is used to reproduce the issue (if applicable)
Any config that uses the same resource multiple times should reproduce it.
```powershell
Configuration Software
{
Import-DscResource -ModuleName Microsoft.WinGet.DSC -Name WinGetPackage
Import-DscResource -ModuleName xPSDesiredStateConfiguration -Name xPackage
Import-DscResource -ModuleName xPSDesiredStateConfiguration -Name xWindowsFeature
$IISFeatures = @(
'Web-Server', 'Web-WebServer', 'Web-Common-Http', 'Web-Default-Doc', 'Web-Dir-Browsing', 'Web-Http-Errors', 'Web-Static-Content', 'Web-Health', 'Web-Http-Logging',
'Web-Http-Tracing', 'Web-Performance', 'Web-Stat-Compression', 'Web-Security', 'Web-Filtering', 'Web-IP-Security', 'Web-App-Dev', 'Web-Net-Ext45', 'Web-AppInit',
'Web-Asp-Net45', 'Web-WebSockets', 'Web-Mgmt-Tools', 'Web-Mgmt-Console', 'Web-Scripting-Tools', 'NET-Framework-45-Features', 'NET-Framework-45-Core', 'NET-Framework-45-ASPNET'
)
$WinGetPackages = @('Microsoft.DotNet.HostingBundle.8', 'Microsoft.Edge', 'Microsoft.PowerShell', 'Microsoft.VisualStudioCode', 'Microsoft.WindowsTerminal')
foreach ($feature in $IISFeatures)
{
xWindowsFeature "Feature-$feature"
{
Name = $feature
Ensure = 'Present'
IncludeAllSubFeature = $false
}
}
foreach ($package in $WinGetPackages)
{
WinGetPackage "WinGet$Package"
{
Id = $package
Source = 'winget'
UseLatest = $true
}
}
xPackage InstallIisArr
{
Name = 'Microsoft Application Request Routing 3.0'
ProductId = '{3C876E4D-B486-49FA-AB33-D94367357A69}'
Path = 'https://download.microsoft.com/download/E/9/8/E9849D6A-020E-47E4-9FD0-A023E99B54EB/requestRouter_amd64.msi'
FileHash = 'FB61FDB7101795A34D5129CB37EEE43AB675C7ED76BA3A3B23B039D8C90C2A4B'
HashAlgorithm = 'SHA256'
}
xPackage InstallIisUrlRewrite
{
Name = 'IIS URL Rewrite Module 2'
ProductId = '{9BCA2118-F753-4A1E-BCF3-5A820729965C}'
Path = 'https://download.microsoft.com/download/1/2/8/128E2E22-C1B9-44A4-BE2A-5859ED1D4592/rewrite_amd64_en-US.msi'
FileHash = '37342FF2F585F263F34F48E9DE59EB1051D61015A8E967DBDE4075716230A32A'
HashAlgorithm = 'SHA256'
DependsOn = '[xPackage]InstallIisArr'
}
}
Software
```
#### The operating system the target node is running
Windows 11 24H2 26100.4349
#### Version and build of PowerShell the target node is running
PSVersion 7.5.2
PSEdition Core
GitCommitId 7.5.2
OS Microsoft Windows 10.0.26100
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
#### Version of the module that was used
GuestConfiguration 4.7.0 C:\Program Files\PowerShell\Modules\GuestConfiguration\4.7.0\GuestConfiguration.psd1
Contributor guide
Assessment
This issue has not been assessed yet.