We've tripped on a bug in PowerShell 5.0 (which seems to be fixed in 5.1) which causes RequiredModules to be extremely slow. This module, which has 11 dependencies, takes a minute to load on my Azure DS1_V2 instance when using RequiredModules, but takes only 6 seconds when removing the RequiredModules and substituting an Import-Module in a psm1 (previously we had no psm1, because this is a pure meta module for install/import purposes).
Last active
March 13, 2018 00:30
-
-
Save Jaykul/0fbd66632f427f0e3dc072c61f4b75cf to your computer and use it in GitHub Desktop.
PowerShell 5.0 Module Loading Bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@{ | |
ModuleVersion = '16.12.1.1' | |
# QMODHelper is a meta module that exists to depend upon all the Questionmark modules, but ... | |
# RequiredModules are limited/broken in PS 5.x so we work around it by importing in a RootModule | |
RootModule = 'Module.psm1' | |
RequiredModules = @() | |
<# | |
RequiredModules = @( | |
# Microsoft modules which are required (at least the first two are required just to parse the module files) | |
'Microsoft.PowerShell.Utility' # Set-Alias, Add-Type | |
'Microsoft.PowerShell.Management' # Out-String | |
'Microsoft.PowerShell.Security' # Get-Credential | |
# Third party dependencies | |
'PSCX' | |
'PowerShellLogging' | |
'Posh-SSH' | |
# The new Questionmark modules, in order | |
'Questionmark.Assemblies' | |
'Questionmark.Database' | |
'Questionmark.Configuration' | |
# The legacy module. | |
'Questionmark.Legacy' | |
# Modules which currently depend on the Legacy module | |
'Questionmark.Tenant' | |
) | |
#> | |
# ID used to uniquely identify this module | |
GUID = '9e121d54-7e76-472c-9133-6adfa3ea37cd' | |
Description = 'The Questionmark OnDemand Deployment helper meta-module depends on all the Questionmark modules as a way of installing and loading them all at once' | |
# Common stuff for all our modules: | |
CompanyName = 'Questionmark Computing Limited' | |
Author = 'Joel Bennett' | |
Copyright = 'Copyright 2016 Questionmark Computing Limited' | |
# Minimum version of the Windows PowerShell engine required by this module | |
PowerShellVersion = '5.0' | |
# Minimum version of the .NET Framework required by this module | |
DotNetFrameworkVersion = '4.0' | |
# Minimum version of the common language runtime (CLR) required by this module | |
CLRVersion = '4.0.30319' | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Import-Module -Global -ErrorAction Stop @( | |
# Microsoft modules which are required (at least the first two are required just to parse the module files) | |
'Microsoft.PowerShell.Utility' # Set-Alias, Add-Type | |
'Microsoft.PowerShell.Management' # Out-String | |
'Microsoft.PowerShell.Security' # Get-Credential | |
# Third party dependencies | |
'PSCX' | |
'PowerShellLogging' | |
'Posh-SSH' | |
# The new Questionmark modules, in order | |
'Questionmark.Assemblies' | |
'Questionmark.Database' | |
'Questionmark.Configuration' | |
# The legacy module. | |
'Questionmark.Legacy' | |
# Modules which currently depend on the Legacy module | |
'Questionmark.Tenant' | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment