
In order to get the Remote Desktop Client to function in a .NET project you must obtain the Remote Desktop ActiveX control wrapper (MSTSCLib.dll and AxMSTSCLib.dll).
MSTSCLib
You may need to unblock the files, since they were downloaded from internet.
File –> Right click –> Properties

Create PowerShell Winform and add Panel control. Additionally add buttons for connect, disconnect, refresh, etc.
Load into your PowerShell script both ActiveX component assemblies:
1 2 |
[system.reflection.Assembly]::LoadFrom("$dllpath\AxInterop.MSTSCLib.dll") [system.reflection.Assembly]::LoadFrom("$dllpath\MSTSCLib.dll") |
where $dllpath is the location of the files.
Create new Object type and add it to the form Panel control:
1 2 3 |
$rdp = New-Object AxMSTSCLib.AxMsRdpClient4NotSafeForScripting $rdp.Dock = 'Fill' $RDPPanel.Controls.Add($rdp) |
Create new on-click event for button “Connect” and fill in the RDP client properties:
1 2 3 4 5 6 7 8 9 10 11 12 |
$rdp.Name = "MyPowerShellRDP" $rdp.Enabled = "true" $rdp.AdvancedSettings2.DisplayConnectionBar = 'true' $rdp.AdvancedSettings2.EnableCredSspSupport = "true" $rdp.ConnectingText = 'Connecting...' $rdp.DisconnectedText = "Disconnected" $groupboxSettings.Enabled = $false $rdp.Server = $textboxServerName.Text $rdp.UserName = $textboxUsername.Text $rdp.AdvancedSettings2.RDPPort = $textboxRDPPort.Text $rdp.AdvancedSettings2.ClearTextPassword = $textboxPassword.Text $rdp.Connect() |
Click here for the Microsoft Remote Desktop ActiveX control client settings reference.



Hello there,
found your application on the technet. Very good job so far!
I have a question regarding this tool:
How did you convert / compile the PowerShell Script to an executable?
Kind Regards,
0x00
Greetings,
Thank you for the feedback!
For compiling the script into exe, I use SAPIEN PowerShell Studio.
Hello,
I have little problem with it. When I trying to run it i get following error:
“The property ‘DisplayConnectionBar’ cannot be found on this object. Verify that the property exists and can be set.
At C:\Scripts\FinalVersion\MigrationMonitoringToolv0.3-test.ps1:770 char:5
+ $rdp.AdvancedSettings2.DisplayConnectionBar = ‘true’
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : PropertyNotFound”
For every properties for $rdp. I dont know what is going on any clue?
There is my code:
$WPFServerTest.Add_Click{
[system.reflection.Assembly]::LoadFrom(“C:\Scripts\FinalVersion\AxInterop.MSTSCLib.dll”)
[system.reflection.Assembly]::LoadFrom(“C:\Scripts\FinalVersion\MSTSCLib.dll”)
$rdp = New-Object AxMSTSCLib.AxMsRdpClient4NotSafeForScripting
$rdp.Dock = ‘Fill’
$WPFtabControl.AddChild($rdp)
$servername = TextInput -Message “Input server name/address:” -WindowTitle “Information” -DefaultText “”
$username = TextInput -Message “Input username:” -WindowTitle “Information” -DefaultText “”
$password = TextInput -Message “Input password:” -WindowTitle “Information” -DefaultText “”
$rdp.Name = “MyPowerShellRDP”
$rdp.Enabled = “true”
$rdp.AdvancedSettings2.DisplayConnectionBar = ‘true’
$rdp.AdvancedSettings2.EnableCredSspSupport = “true”
$rdp.ConnectingText = ‘Connecting…’
$rdp.DisconnectedText = “Disconnected”
$groupboxSettings.Enabled = $false
$rdp.Server = $servername.Text
$rdp.UserName = $username.Text
$rdp.AdvancedSettings2.RDPPort = 3389
$rdp.AdvancedSettings2.ClearTextPassword = $password.Text
$rdp.Connect()
}
Best regards
Kamil
I got the same thing sadly.
I got the same thing sadly. I fixed it by using ISE x32 in lieu of x64. LoadAsm is biased on CPU architecture.
Hi,
Can you please tell me if using this tool the rdp session would be established on machines outside domain connected via internet?
Thanks for this tool… But is there any possibility to get the source of the full program ?
Regards,
MaG