1

I can't recall if this stopped working at some point or has always been this way. When I develop powershell modules I would like to be able to load them explicitly from my local repo directory to make sure everything is working properly. MSDN indicates this should work, however I get the error:

"The specified module .\SomeModule was not loaded because no valid module file was found in any module directory. FileNotFoundException"

I would expect this is because it can't find the psm1 file in the directory but I can't understand why. I can load the module by referencing the psm1 file directly but this excludes anything being loaded by the manifest. I can also copy the module to one of the standard module paths and it will load correctly. This is what I've been doing as a work around but I'd love to get this figured out. TIA

**Update: Ran process monitor while running the import command. Interesting results. Seems like it may just be a powershell bug.

Load from explicit path

4
  • You can load a module by referencing the module manifest file directly. Commented Mar 23, 2017 at 14:00
  • Ahh, that did work. I thought I tried that before but I wonder if I hadn't specified the psm1 file in the RootModule property yet. I'll check that and the ModuleList to see what effect it has on things loading properly like that. If no one else has anything to say about loading it using the folder path as shown on msdn I'll mark you answer as correct. It suits my needs just fine. Thanks! Commented Mar 23, 2017 at 14:06
  • Is the module manifest (.psd1) filename the same as the folder? eg ...\MyModule\MyModule.psd1? If they aren't the same then you have to explicitly reference the manifest filename when loading the module. If they match then you can just provide the folder path without manifest filename. Commented Mar 23, 2017 at 14:36
  • @JamesC. They are named the same. Definitely strange behavior. Commented Mar 24, 2017 at 2:11

1 Answer 1

1

You can load the module by referencing the module manifest file (.psd1) directly, which will then ensure any dependencies are loaded.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.