Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save sdoubleday/19f133f6cf619ca9200b021664314d7a to your computer and use it in GitHub Desktop.

Select an option

Save sdoubleday/19f133f6cf619ca9200b021664314d7a to your computer and use it in GitHub Desktop.
Why is my PowerShell .psd1 manifest running scripts from present working directory, NOT the module directory?
<#
Why? I don't know why. But mechanically, when you import a manifest, the paths to scripts to process are checked first in the
present working directory $PWD, and THEN in the manifest's parent folder. Thus, if you have the same named script in both your PWD
and in the module folder, when you load the module it will run the script in your PWD, NOT the one in the module.
Thankfully, instead of doing this in your manifest:
ScriptsToProcess = @(".\myScript.ps1")
you can this:
ScriptsToProcess = @("$PSScriptRoot\myScript.ps1")
PLEASE NOTE! THIS DOES NOT APPLY TO NESTED MODULES! Those still need to be relative-referenced.
#>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment