Skip to content

Instantly share code, notes, and snippets.

@bielawb
Created February 13, 2017 22:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bielawb/6c6632ec95d6f6779f8fdf21b465f298 to your computer and use it in GitHub Desktop.
Save bielawb/6c6632ec95d6f6779f8fdf21b465f298 to your computer and use it in GitHub Desktop.
Two options for script-per-function module design
# Works fine in "normal" environment, can become slow when network is more complex...:
foreach ($file in Get-ChildItem $PSScriptRoot\*.ps1) {
. $file.FullName
}
# Should be fast everywhere, but it's bit more complex...
foreach ($file in Get-ChildItem $PSScriptRoot\*.ps1) {
. (
[scriptblock]::Create(
[io.file]::ReadAllText($file)
)
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment