Last active
July 12, 2018 18:08
-
-
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?
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
| <# | |
| 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