Change the title bar of an RDP session launched from Powershell

Hi

TOtally new to Powershell but was asked to try and create a script that will launch an RDP Session on a remote server for my users.

I have managed to do this using the following and this works fine:-

Clear-Host
$AWSUserName=“JBooth”
$BastionSSH=“sshbastion1.A033428337079.amazonaws.com
$ServerIP=“10.106.106.125”
$LocalPort=“1004”
$env:computername

Pre-Reqs Checks.

$PuttyInstalled=“”
$PuttyPath=“C:\Program Files\PuTTY\Putty.exe”
IF(Test-Path “${PuttyPath}”){
$PuttyInstalled=“Yes”
} ELSE {
Read-Host “You either do not have putty installed or the path to the Putty executable is not installed in the default location.”
Read-Host “Please validate Putty is installed (if not download from here and install using the default values : https://www.putty.org/ ) or modify the path in this script to the correct location where you installed it.”
Exit
}

Setting the password to be used for the SSH bastion authentication.

$Value=Read-Host “Please enter your UK1HCC Password” -AsSecureString
$bstr=[System.Runtime.InteropServices.Marshal]::SecureStringToBSTR($Value)
$Password=[System.Runtime.InteropServices.Marshal]::PtrToStringAuto($bstr)

Creating the SSH tunnel.

$ArgumentList=“-ssh "${AWSUserName}@uk1hcc@${BastionSSH}” -pw "$Password" -L ${LocalPort}:${ServerIP}:3389"
$PuttyPath=“C:\Program Files\PuTTY\Putty.exe”
IF($PuttyInstalled -eq “Yes”){
Start-Process “${PuttyPath}” -ArgumentList $ArgumentList
Start-Sleep -Seconds 1
}

Creation of the RDP connection.

$mtscArgList=“/v 127.0.0.1:${LocalPort} /f”
Start-Process “C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection” -ArgumentList $mtscArgList

My issue that no matter how much I read I cannot resolve is that once the rdp session has launched from this in the title bar of the rdp window it displays 127.0.0.1:1004 Remote Desktop Connection.

What I am looking for is the name of the server to be displayed in the title bar instead of the IP address and Port Number.

If anyone could offer any advice on this it will be much appreciated.

I dont think that is easily done. I saw nothing as an argument to the RDP exe or a setting in the connection file if you chose to use that.

There is mention in google of setting up DNS Aliases (or the local hosts file) and using that to get the wanted description.

1 Like