Create a PowerShell GUI application to perform remote desktop operation using Microsoft Remote Desktop ActiveX control

PowerShell RDC
PowerShell Remote Desktop Client

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

Unblock File
Unblock File Downloaded from Internet

Create PowerShell Winform and add Panel control. Additionally add buttons for connect, disconnect, refresh, etc.

Load into your PowerShell script both ActiveX component assemblies:

where $dllpath is the location of the files.
Create new Object type and add it to the form Panel control:

Create new on-click event for button “Connect” and fill in the RDP client properties:

Click here for the Microsoft Remote Desktop ActiveX control client settings reference.

facebooktwittergoogle_plus

5 thoughts on “Create a PowerShell GUI application to perform remote desktop operation using Microsoft Remote Desktop ActiveX control”

  1. 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

    1. Greetings,
      Thank you for the feedback!
      For compiling the script into exe, I use SAPIEN PowerShell Studio.

  2. 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

  3. Hi,

    Can you please tell me if using this tool the rdp session would be established on machines outside domain connected via internet?

  4. Thanks for this tool… But is there any possibility to get the source of the full program ?

    Regards,
    MaG

Leave a Reply

Your email address will not be published. Required fields are marked *