Skip to content

Instantly share code, notes, and snippets.

@adbertram
Created September 7, 2017 15:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adbertram/c3df3bd50d14f869d24d1c5f81d58750 to your computer and use it in GitHub Desktop.
Save adbertram/c3df3bd50d14f869d24d1c5f81d58750 to your computer and use it in GitHub Desktop.
##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