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).
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:
where $dllpath is the location of the files.
Create new Object type and add it to the form Panel control:
$rdp = New-Object AxMSTSCLib.AxMsRdpClient4NotSafeForScripting
$rdp.Dock = 'Fill'
Create new on-click event for button “Connect” and fill in the RDP client properties:
$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