Reputation: 149
I followed the demo here for creating a custom powershell cmdlet. When I attempt to import the module, I get the following error:
C:\PS> Import-Module DemoPS.dll
Import-Module : The specified module 'DemoPS.dll' was not loaded because no valid module file was found in any module directory.
If anymore info is needed, let me know.
Upvotes: 1
Views: 4362
Reputation: 54971
The error is shown because it can't find your dll file. You need to specify full path for your modules DLL file (e.g. Import-Module c:\users\mj\desktop\DemoPS.dll
).
As an alternative solution, you can save it in your "module" folder. This is a folder called "Modules" that you have to create in your profile directory. Your profile directory can be found using $profile
. It is normally in C:\Users\<username>\Documents\WindowsPowerShell\
. So to use this, place your dll in following path:
C:\Users\<username>\Documents\WindowsPowerShell\Modules\DemoPS\DemoPS.dll
Upvotes: 6