Reputation: 11
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()
Upvotes: 1
Views: 4118
Reputation: 467
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.
Upvotes: 1