Forum / Remote Desktop Manager - PowerShell Repository

RDM CMDlets under 64 bit

  • Create an Issue
  • Cancel

Hi, i just thought i share this tiny bit of code.

Explanation: RDM cmdlets do NOT load in 64 bit Powershell.

I use this to run my New-Session script from standard 64 bit Powershell environment.
supports all Parameters

if ([Environment]::Is64BitProcess) {
$Myself = $Myinvocation.line
Write-Host ".Running in 64 Bit, Restarting in 32 bit '$Myself'"
& $env:windir\syswow64\WindowsPowerShell\v1.0\powershell.exe $Myself
return 0
}


$RDMSnapin = Get-PSSnapin -Name *Remote.Desktop* -Registered -ErrorAction SilentlyContinue | sort version -Descending | select -First 1
Add-PSSnapin $RDMSnapin -ErrorAction SilentlyContinue
$AddRC = (Get-Command *rdm*).count

Write-Host ".Adding RDM Snapin: $($RDMSnapin.Name), Loaded cmdlets: $AddRC"
[/CODE]

Clock6 yrs

Peter,

Thank you for sharing your script.

We've have a dev looking at our PowerShell cmdlet. We will be adding new cmdlets and making them more pipeline friendly. Also note, we will also try to enable the cmdlet in PowerShell x64.

I see what you did there. Sorting the list to get the latest version of the PSSnapin. We've added a to-do to cleanup old PSSnapin registrations during the setup.

Best regards,

Stefane Lavergne

signaturesignature

Clock6 yrs

Good to hear Applause
(Your'e missing a Thumbs up Smiley)

Clock6 yrs

Please i really need your Snapin (or better a module) to run in 64 bit.

To clean up your old versions once in a while is use this dirty workaround:
(Be careful, it manipulates the Registry so i spelled the cmdlet after the pipe wrong ;-)!
[CODE]
Get-ChildItem HKLM:\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns | where {$_.name -like "*Remote.Desktop.Manager.10.*"} | Rem0ve-I7em
[/CODE]

Clock6 yrs

F.Y.I You can now run the CmdLet under x64 or x86 PowerShell.


Make sure you change the install folder and version(name)

set-alias installutil "$([System.Runtime.InteropServices.RuntimeEnvironment]::GetRuntimeDirectory())installutil.exe"

installutil "C:\Program Files\10.1.3.0\RemoteDesktopManager.PowerShell.dll"

if ( (Get-PSSnapin -Name Remote.Desktop.Manager.10.1.3 -ErrorAction SilentlyContinue) -eq $null ) { Add-PsSnapin Remote.Desktop.Manager.10.1.3 }


F.Y.I. new in v10.1.4.0 if you start RDM x64 and launch the PS session from the Tools-> "PowerShell (RDM CmdLet)" it will start PS x64 & register the RDM CmdLet in x64. The same is true for x86, it will register in x86.

Best regards,

Stefane Lavergne

signaturesignature

Clock5 yrs

You can run 32 bit RDM Cmdlets from 64bit Powershell. Here's how. Do all the following on the machine that has RDM installed, of course.

1. Enable PSRemoting. This only needs done once, not every time you want to use RDM Cmdlets. If you've already enabled it, skip this step.

Enable-PSRemoting -Force

2. Start a 32bit "remote" (it's actually local) session.

$Session32 = New-PSSession -ConfigurationName microsoft.powershell32

3. Load the RDM Snapin in the session. This assumes the RDM PS dll has already been registered.

Invoke-Command -Session $Session32 -ScriptBlock {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; } }}

4. Import the RDM Cmdlets into your current (64bit) session.

$RDMModule = Import-PSSession $Session32 -CommandName *-RDM*

You can now use 32bit RDM Cmdlets in your 64bit PowerShell!

Get-RDMCurrentDataSource

Etc.

If and when you're done using RDM Cmdlets, do this:

Remove-Module $RDMModule.Name
Remove-PSSession $Session32

Clock5 yrs

Dale,

Great tip, thanks for sharing.

Best regards,

Stefane Lavergne

signaturesignature

Clock5 yrs