Issues importing the module into win7, ps 3.0

Feb 26, 2013 at 9:15 PM
I'm fairly new to Powershell but not new to scripted and automated testing. Trying to import the UIAutomation.0.8.5.NET40 dll and I'm getting an error:

Import-Module : Could not load file or assembly
'file:///C:\Windows\system32\WindowsPowerShell\v1.0\Modules\UIAutomation\UIAutomation.dll' or one of its dependencies. Operation
is not supported. (Exception from HRESULT: 0x80131515)

I'm running Powershell 3.0 as Administrator, with my execution policy currently set wide open as unrestricted. I've even downloaded version 0.7.5 to grab the certificate and went through installing the certificate, still not getting past this error. I've even tried the Net3.5 version on Powershell 2.0 in Windows Server 2008R2 which does load but gives me some different errors:

Import-Module : Cannot load Windows PowerShell snap-in C:\Windows\system32\WindowsPowerShell\v1.0\Modules\UIAutomation\
UIAutomation.dll because of the following error: Unable to load one or more of the requested types. Retrieve the Loader
Exceptions property for more information.
Loader Exceptions:
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'UIAutomationTypes, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e
35' or one of its dependencies. The system cannot find the file specified.
Could not load file or assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e
35' or one of its dependencies. The system cannot find the file specified.
At line:1 char:14

Any help you can give is appreciated. I can't figure out what I'm doing wrong. Thanks in advance.

JMH
Coordinator
Feb 26, 2013 at 10:19 PM
Edited Feb 26, 2013 at 10:22 PM
Hi jmh_dt,
might it be the TOP 1 reason: files are blocked (working in a networked environment, I face this problem almost everyday when I copy such files as scripts, dlls, even content of archives...).
PS C:\Users\administrator> ipmo C:\uia\UIAutomation.dll
ipmo : Could not load file or assembly 'file:///C:\uia\UIAutomation.dll' or one of its dependencies. Operation is not
supported. (Exception from HRESULT: 0x80131515)
At line:1 char:1
  • ipmo C:\uia\UIAutomation.dll
  • ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    • CategoryInfo : NotSpecified: (:) [Import-Module], FileLoadException
    • FullyQualifiedErrorId : System.IO.FileLoadException,Microsoft.PowerShell.Commands.ImportModuleCommand
The cure is simple: just open files' properties and click the Unblock button (alternatively, unblocking the zip archive may also help).
I checked this on a Windows 8 box with PS3.0 and PS 2.0 enabled - the same error, the same cure.

I simple don't remember what was shiiped within 0.7.5 release, probably, some files that are gone by now. Or the same problem: Windows blocked all you have downloaded.
Feb 27, 2013 at 2:13 PM
I downloaded sysinternals Streams.exe and used it on the files, worked perfectly, thank you.

I still have an issue with the Win Serv 2008R2 with Powershell 2.0 though. Not the same error. Says it's unable to retrieve the requested types, I had captured it in the original posting. I am using the net 35 version there, any insight as to how to resolve this message, if it is going to be a problem, etc, I would appreciate it.

JMH
Coordinator
Feb 27, 2013 at 7:27 PM
Hi jmh_dt,
I tried to reproduce the issue on a Windows 2008 R2 but failed. I used an Amazon default Windows 2008 R2 SP1 instance (with contemporary updates including PS 3.0), under a local administrator (the default user Amazon/Microsoft provides), all three versions (0.8.5 .NET35, 0.8.5 .NET40, 0.8.5 for Metro UI) of UIAutomation.dll have been loaded without a problem from %systemroot%\system32\WindowsPowerShell\Modules\UIAutomation\UIAutomation.dll.

As on your system such assemblies as UIAutomationTypes and PresentationFramework could not be loaded, your system is Core or something with minimal .NET (though even 3.5 Client Profile contains these assemblies). Is it not a Core box?
Feb 28, 2013 at 8:58 PM
Not worth fighting with it, I installed Powershell 3.0 on the system in questions and proceeded. Thanks for you assistance and for the terrific tool.
Coordinator
Feb 28, 2013 at 9:25 PM
Excellent!
Thanks for a recipe: PS 3.0 over PS 2.0 may heal some misconfiguration in .NET 3.x.