NOTE: this script requires the Quest Active Directory cmdlets
#generate-rdpfiles.ps1
$input = Get-QADComputer -ErrorAction SilentlyContinue -SizeLimit 0 | Where-Object { $_ .operatingsystem -match “Server” }
$RDPRoot = ‘C:\RDP-Files’
if ( -not ( Test-Path -Path $RDPRoot )) {
New-Item -Path $RDPRoot -ItemType Directory | Out-Null
}
$input | ForEach-Object {
$path = “$RDPRoot\$($_.Name).rdp”
$rdpfile = Test-Path -Path $path
if ( $rdpFile -eq $true ) {
Clear-Content -Path $path
}
Add-Content -Path $path -Force -Value @”
screen mode id:i:1
desktopwidth:i:1152
desktopheight:i:864
session bpp:i:16
winposstr:s:0,1,0,0,1032,795
full address:s:$($_.Name)
compression:i:1
keyboardhook:i:2
audiomode:i:2
redirectprinters:i:0
redirectcomports:i:0
redirectsmartcards:i:1
redirectclipboard:i:1
redirectposdevices:i:0
drivestoredirect:s:*
displayconnectionbar:i:1
autoreconnection enabled:i:1
authentication level:i:0
prompt for credentials:i:0
negotiate security layer:i:1
remoteapplicationmode:i:0
alternate shell:s:
shell working directory:s:
disable wallpaper:i:0
disable full window drag:i:0
allow desktop composition:i:1
allow font smoothing:i:1
disable menu anims:i:0
disable themes:i:0
disable cursor setting:i:0
bitmapcachepersistenable:i:1
gatewayhostname:s:
gatewayusagemethod:i:0
gatewaycredentialssource:i:4
gatewayprofileusagemethod:i:1
“@
}
PowerGUI - Administrative Powershell Console : Generate rdp-files from AD …


















0 Responses to “Powershell Script : Generate rdp-files from AD”