Pscx on Powershell 3.0 beta?

Topics: User Forum
Apr 26, 2012 at 8:41 PM

After installing Pscx 2.1 Beta 1 on top of the Powershell 3.0 beta (Windows Management Framework 3 beta), I see the following error when trying to load the module (import-module pscx):

Import-Module : Could not load file or assembly 'Pscx.Core, Version=2.0.3782.38614, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

All of the files are 'unblocked' appropriately.

I did see in the release notes for psh 3.0 that a code change of modules is probably required because of .net 4.0 compatibility issues.  Is it supposed to be working?

May 1, 2012 at 4:35 AM

Is this on Windows 8?  If so, we've noticed that the something in the OS (perhaps IE) is caching the "blocked" status of a file such that even after unblocking the file it appears as blocked.  A reboot will usually rectify that but you can also run: "powershell.exe -ExecutionPolicy Unrestricted" and then try to import PSCX.

May 1, 2012 at 7:09 AM

This is Windows 7, 32-bit. 

I tried the "powershell.exe -ExecutionPolicy Unrestricted" command anyway, and it yields the same error.  This is also after a reboot.

May 1, 2012 at 9:05 AM
Edited May 1, 2012 at 9:06 AM

I figured it out. 

As I was upgrading, I temporarily moved the old pscx folder out of the Modules directory (into C:\Windows\System32\WindowsPowerShell\v1.0).  Apparently, that is still in the search path for modules (presumably higher, too) because when import-module was run, it still wound up loading pscx.dll out of that sub-directory.  renaming that directory from pscx to something else fixed the problem.

Interestingly, that may mean it's not technically necessary for modules to be placed in the modules folder.  When I ran procmon, it looked like powershell might even have been searching the whole path.