PowerShell runtime exception - "could not load file or assembly"

Solution in this case: Remove and download it all again. I even unblocked it on the first file, with no help. Glad this was on an internal machine.


The file may be blocked from being loaded because of its origin (stored in NTFS streams). Check properties and see if the little unblock button is lit up. Once you unblock it perhaps it will load...


The following worked for me (from Stack Overflow question Add-Type load assembly from network UNC share error 0x80131515).

In files:

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

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
   <runtime>
      <loadFromRemoteSources enabled="true"/>
   </runtime>
</configuration>

Import-Module : Could not load file or assembly 'file:/// *dll path*' or one of 
its dependencies. An attempt was made to load a program with an incorrect format.
At *script path*.ps1:68 char:2
+     Import-Module *module path*
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], BadImageFormatException
    + FullyQualifiedErrorId : System.BadImageFormatException,Microsoft.PowerShell.Commands.ImportModuleCommand

If you see the above error, it might be the issue of running the Windows PowerShell ISE in 32 bit mode(Windows PowerShell ISE(x86)). You have to run the application Windows PowerShell ISE.

This application(Windows PowerShell ISE) is in 64 bit mode. When I executed the power shell command, its working fine for me.

I have been trying to fix this with different types solutions but it doesn't worked for me. If you running it 32 mode, switch it to 64 bit and try.