Skip to content

Instantly share code, notes, and snippets.

@kennystrawnmusic
Last active December 2, 2025 09:10
Show Gist options
  • Select an option

  • Save kennystrawnmusic/0903ea22c308b91bf975e233defb9360 to your computer and use it in GitHub Desktop.

Select an option

Save kennystrawnmusic/0903ea22c308b91bf975e233defb9360 to your computer and use it in GitHub Desktop.
function Gen-RDPFile {
Param (
[string]$User,
[string]$Password,
[string]$IP,
[string]$FileName,
[int]$Width = 2880,
[int]$Height = 1620,
[int]$Port = 3389,
[bool]$FullScreen = $false
)
$enc = ConvertTo-SecureString $Password -AsPlainText -Force | ConvertFrom-SecureString
$screenMode = if ($FullScreen) {
2
} else {
1
}
if ($(Test-Path -Path '\\tsclient\c')) {
net use E: '\\tsclient\c'
} elseif ($(Test-Path -Path '\\tsclient\e')) {
net use E: '\\tsclient\e'
}
$fileContents = @"
screen mode id:i:$screenMode
use multimon:i:0
desktopwidth:i:$Width
desktopheight:i:$Height
session bpp:i:32
winposstr:s:0,1,465,143,3363,1810
compression:i:1
keyboardhook:i:2
audiocapturemode:i:0
videoplaybackmode:i:1
connection type:i:7
networkautodetect:i:1
bandwidthautodetect:i:1
displayconnectionbar:i:1
enableworkspacereconnect:i:0
disable wallpaper:i:0
allow font smoothing:i:0
allow desktop composition:i:0
disable full window drag:i:1
disable menu anims:i:1
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
full address:s:${IP}:${Port}
audiomode:i:0
redirectprinters:i:1
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
autoreconnection enabled:i:1
authentication level:i:2
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
gatewayhostname:s:
gatewayusagemethod:i:4
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:0
promptcredentialonce:i:0
gatewaybrokeringtype:i:0
use redirection server name:i:0
rdgiskdcproxy:i:0
kdcproxyname:s:
remoteappmousemoveinject:i:1
redirectlocation:i:0
redirectwebauthn:i:1
enablerdsaadauth:i:0
drivestoredirect:s:*
username:s:$User
password 51:b:$enc
"@;
$fileContents | Out-File -FilePath $PWD\$FileName.rdp -Force
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment