5.1 Env. Scripts not executing after Upgrade to 5.0

Product: PowerShell Universal
Version: 5.0

since upgrading to 5.0 all scripts executed within the 5.1 environment fail with following error:

Import-Module : Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, 
PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
At C:\Program Files (x86)\Universal\UniversalHost.psm1:9 char:5
+     Import-Module $LocalHost
+     ~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : System.IO.FileNotFoundException,Microsoft.PowerShell.Commands.ImportModuleCommand
 
Exception calling "StartJob" with "3" argument(s): "Could not load file or assembly 
'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its 
dependencies. The system cannot find the file specified."
At C:\Program Files (x86)\Universal\UniversalHost.psm1:28 char:13
+             [UniversalHost.AgentService]::StartJob($Port, $ParentProc ...
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : FileNotFoundException

Do you maybe have multiple version of the Universal module installed, maybe causing a conflict?

You can run Get-Module Universal* -List and share the output.

This is likely because PSU is calling powershell.exe directly. We need to make this more adaptable and will be fixed in 5.0.2. In the meantime, I would check to see if you have a Windows PowerShell environment with the path to powershell.exe. Try changing the path to “Windows PowerShell 5.1” and it will use the new hosting executable rather than powershell.exe and will load assemblies properly.

3 Likes

This caught me a bit off guard as well, it appears that Universal can’t (or won’t?) change existing environments to use the new hosting executable, I ended up deleting all the old environments to generate the right ones.

We can make PSU change the behavior for this. Miss on our part.

2 Likes