PowerShell Add-On Fails

avatar

Any idea why this is occurring? We have .NET 4.5.2 installed on the server we are launching the RDM.


Loading RDM CmdLet (Snap-in)

Microsoft (R) .NET Framework Installation utility Version 2.0.50727.5483

Copyright (c) Microsoft Corporation. All rights reserved.


Exception occurred while initializing the installation:

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Program Files (x86)\Devolutions\Remote Desktop Manager\RemoteDesktopManager.PowerShell.dll' or one of its dependenc

es. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded..


Thank you.

All Comments (3)

avatar

Hi Orhan,


Can you do $PSVersionTable after the installation failed, I think it's a version problem.


If the value of CLRVersion is not 4. You need to modify powershell.exe.config in C:\Windows\System32\WindowsPowerShell\v1.0 (32bits) and C:\Windows\SysWOW64\WindowsPowerShell\v1.0 (64 bits) if the file doesn't exist create one with the name powershell.exe.config.


Copy and paste this in the config file:


<configuration>

<startup useLegacyV2RuntimeActivationPolicy="true">

<supportedRuntime version="v4.0.30319"/>

<supportedRuntime version="v2.0.50727"/>

</startup>

</configuration>

Best regards,

Olivier Désalliers

avatar

Thanks Olivier. That worked.


Now i am running into separate issue. when i tried to load the snap-in from the RDM menu tools it works fine but when i tried to load the snap-ins from regular powershell window with the command specified in the documentation:


Get-PSSnapin -Name *Remote.Desktop* -Registered | % { Write-Host "$_..." -NoNewline; if ( (Get-PSSnapin -Name $_ -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "installing" -ForegroundColor Yellow; Add-PsSnapin $_ } else { Write-Host "already installed" -ForegroundColor Green; } }


for some reason the snap-in does not get loaded. is there any other way to get this working?


thank you.

avatar

Hi,


You need install the snap-in first, you can use this code to install it:


set-alias installutil "$([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())installutil.exe" ;installutil ' [i][b]InstallPath [/b][/i]\RemoteDesktopManager.PowerShell.dll';Get-PSSnapin -Name *Remote.Desktop* -Registered | % { Write-Host "$_..." -NoNewline; if ( (Get-PSSnapin -Name $_ -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "installing" -ForegroundColor Yellow; Add-PsSnapin $_ } else { Write-Host "already installed" -ForegroundColor Green; } }

This will install and load the snap-in. Don't forget to change the "InstallPath" to where RDM is installed on your computer.


After you installed it once, you should be able to use this code to load the snap-in when you want to use it or you can add it to your PowerShell profile:


Get-PSSnapin -Name *Remote.Desktop* -Registered | % { Write-Host "$_..." -NoNewline; if ( (Get-PSSnapin -Name $_ -ErrorAction SilentlyContinue) -eq $null ) { Write-Host "installing" -ForegroundColor Yellow; Add-PsSnapin $_ } else { Write-Host "already installed" -ForegroundColor Green; } }

Best regards,

Olivier Désalliers