Skip to main content

KB-CP160001

Last modified at 2/5/2016 5:08 PM by Thomas Carpe

​Fix: "Import-Module : Could not load file or assembly"


Summary:

This is an issue that affected pre-release versions of CloudPower. It has been resolved by including a Windows Installer package to automate the process of deploying files to the correct locations.


Description of Issue:

After installing CloudPower and trying to run commands or scripts, you may see an error similar to this one.

 

Import-Module : Could not load file or assembly

'file:///C:\Users\xxx\Documents\WindowsPowerShell\Modules\CloudPower\LiquidMercury.SharePoint.Client.PowerShell.dll'

or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

At C:\Users\xxx\documents\WindowsPowerShell\Modules\Examples\Import Content Types\Provision-InfoArch.ps1:5 char:1

+ Import-Module CloudPower

+ ~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileLoadException

    + FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand

 

Causes:

This can occur because the DLLs have been installed to the WindowsPowerShell\Modules folder from a ZIP file and Windows has blocked them from execution.

 

This can also occur if your PowerShell EXE does not support the correct version of the .NET framework.

 

Solution 1:

 

Unblock the ZIP file before you extract. Otherwise you will have to individually unblock each file separately.

 

More info: http://stackoverflow.com/questions/13799260/powershell-runtime-exception-could-not-load-file-or-assembly

 

Solution 2:

 

Make sure that you have added the necessary .NET framework versions to the PowerShell configuration files. CloudPower is currently built on .NET framework 4.5. These configuration files are located at:

 

  • C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe.config
  • C:\Windows\System32\WindowsPowerShell\v1.0\powershell_ise.exe.config

 

For example:

 

    <startup useLegacyV2RuntimeActivationPolicy="true">

        <supportedRuntime version="v2.0" />   

        <supportedRuntime version="v3.5" />   

        <supportedRuntime version="v4.0" />   

        <supportedRuntime version="v4.5" />   

        <supportedRuntime version="v4.6" />   

    </startup>