Blub
Blub

Reputation: 13664

Powershell Import-Module fails with DllNotFoundException

Trying to use http://powershellgac.codeplex.com on another computer with powershell 2.0, using it successfully in powershell 3.0 on my main pc but shows this on the other pc:

Get-Module -ListAvailable

Manifest AppLocker            {}
Manifest PSDaignostics        {}
Manifest TroubleshootingGPack {}
Manifest Gac                  {}
Manifest Gac                  {}
Manifest Gac                  {}

The brackets are all filled on my main pc, why isn't this working? I have set the ExeuctionPolicy to "unrestricted". Still the same error. I have set the $env:PSModulePath correctly on both pcs. (how else would it find the Gac manifest at all)

EDIT: I forgot to add the most important info: When I start the .ps1 script inside Powershell ISE then it works, even on the other pc. So clearly there's nothing wrong with the script itself, so I'm clueless.

Upvotes: 1

Views: 429

Answers (1)

Lars Truijens
Lars Truijens

Reputation: 43645

-ListAvailable lists all the modules it can find on your machine, but those modules are not necessarily loaded (using import-module). PowerShell 2.0 does not show the exported commands until a module is loaded, but PowerShell 3.0 does. Also see here. If you want to see the exported commands from a loaded module try Get-Module.

The results of the command are no reason to believe that the module is not working.

I'm the author of the PowerShell GAC module and I want to thank your for trying it out. Please add the complete error message details when loading the module so we can figure out what the problem is.

Execute dir ((Get-ItemProperty HKLM:Software\Microsoft\.NetFramework -Name InstallRoot).InstallRoot) in both the PowerShell console and the ISE and let me know what results you are getting.

Upvotes: 1

Related Questions