powershellwrapper icon indicating copy to clipboard operation
powershellwrapper copied to clipboard

Exception from HRESULT: 0x80131047

Open ecspresso opened this issue 4 years ago • 2 comments

Steps to reproduce

Import-Module IT GlueAPI

Expected behavior

The module is imported

Actual behavior

Error: The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)

 

Running from Windows causes not problem at all. Running it from our RMM generated the above error. Someone had the same problem in PowerShell/PowerShell#3059 and this was the solution:

My RootModule in my .psd1 was prefixed with .\. Perhaps this may help.

Changing it from '.\ITGlueAPI.psm1' to "$PSScriptRoot\ITGlueAPI.psm1" solves the issue while still referencing the the correct path.

 

I will create a pull request.

ecspresso avatar Jul 05 '21 07:07 ecspresso

I think RootModule should omit the path prefix entirely. See Microsoft's documentation and example for RootModule. Using the root module name only has worked for me in my own modules.

RootModule = "ITGlueAPI.psm1"

davidhaymond avatar Jul 23 '21 16:07 davidhaymond

@davidhaymond You are most likely right but I cannot test this at the moment so I will leave it as is and let someone with more knowledge on the subject decide what to do.

ecspresso avatar Aug 24 '21 19:08 ecspresso