1

Does anybody have a Powershell script that generates a RDP icon on the desktop of the user. I already have the code for the desktop icon creation. But the next thing I need is the RDP extension to be created with specific paramters (Single usage of monitor)

Thanks in advance!

$wshshell = New-Object -ComObject WScript.Shell
$lnk = $wshshell.CreateShortcut("C:\Users\Public\Desktop\RDP.lnk")
$lnk.TargetPath = "C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Accessories\Remote Desktop Connection.lnk"
$lnk.Description = "RDP"
$lnk.Save()
nimizen
  • 3,345
  • 2
  • 23
  • 34
Ghostky
  • 11
  • 3
  • Your current target is a shortcut that points to mstsc, this is the executable that created the remote desktop connections. Check `mstsc /?` and create a custom target with the required arguments. – nimizen Nov 23 '21 at 13:18

1 Answers1

1

You did it almost correct. But better to set TargetPath to mstsc.exe directly. Use $lnk.Arguments to set parameters like server name (/v), fullscreen (/f) and others.

$wshshell = New-Object -ComObject WScript.Shell
$lnk = $wshshell.CreateShortcut("C:\Users\Public\Desktop\RDP.lnk")
$lnk.TargetPath = "%windir%\system32\mstsc.exe"
$lnk.Description = "RDP"
$lnk.Arguments = "/v:server-1 /f"
$lnk.Save()

If you need some tweaks inside mstsc its better to use shared folder for all computers and place .rdp file with your config here. After that use $lnk.TargetPath to this .rdp file.

Alex R.
  • 467
  • 3
  • 14
  • Could you give me an example with all parameters? Thanks in advance – Ghostky Nov 23 '21 at 14:40
  • @Ghostky [Here is link to Microsoft Docs](https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/mstsc). BTW if my answer was correct for you, please do not forget to mark it as solving, Thanks! – Alex R. Nov 24 '21 at 10:40