Created
September 7, 2017 15:03
-
-
Save adbertram/c3df3bd50d14f869d24d1c5f81d58750 to your computer and use it in GitHub Desktop.
This file contains 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
##foo.psm1 | |
##################### | |
$ServiceAppMap = @{ | |
RAS = 'Web' ## DeployWebApplication | |
EDW = 'Custom' ## Has it's own Install-<App> function | |
LSA = 'Custom' | |
LDI = 'Custom' | |
LDA = 'Web' | |
LAE = 'Web' | |
} | |
## Make the enum for param validation | |
Invoke-Expression ('enum GHIApplication {{{0}}}' -f [string]$ServiceAppMap.Keys.foreach({ "$_;" })) | |
function thing { | |
param( | |
[GHIApplication]$app | |
) | |
} | |
###################### | |
PS> Import-Module foo.psm1 | |
PS> thing | |
Unable to find type [GHIApplication] | |
## If I manually run `Invoke-Expression ('enum GHIApplication {{{0}}}' -f [string]$ServiceAppMap.Keys.foreach({ "$_;" }))` | |
## in the console and then try to run `thing`, it then finds the type. | |
## It’s acting like during module import, it doesn’t create the enum at all. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment