to enable RDP on 1 server its quite simple if you’re using the server GUI –
System Properties/Remote tab
but on a complex environment you might consider the use of the GPO tool by creating a dedicated gpo for it.
- Navigate to Computer Configuration, Policies, Administrative Templates, Network, Network Connections, Windows Firewall, Domain Profile.
- Double-click Windows Firewall: Allow inbound Remote Desktop exception.
there’s also another way to enable RDP on remote or local Computer / Servers via Powershell ,using the WMI
with this line you can get the details of the Terminal feature status –
1 |
Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -ComputerName $Computer |
Note ! in order to query servers on your network with WMI ,you must enable it via firewall/gpo.
if the status of the value “AllowTSConnections” is 0 ,then the RDP feature is disabled.
to change it you’ll need to run the following line –
1 |
(Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -ComputerName localhost).setallowConnections(1,1) |
to make it even more simple iv’e created a function that will check the status of the Terminal Server Settings on a Remote or local server ,it’ll show you the status and
it can also change it by typing “Enable”
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function RRDP ($computer = localhost) { $RDPStatus = Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace root\CIMV2\TerminalServices -ComputerName $Computer if ($RDPStatus.AllowTSConnections -eq "0") { Write-Host "Terminal Server Mode on Server is Disabled ` would you like to enable RDP on Remote Server?" -BackgroundColor Black -ForegroundColor Red $read =Read-Host "Enable RDP ? 'Please Enter Enable" if ($read -eq "Enable") { $result = $RDPStatus.SetAllowTsConnections(1,1) if($result.ReturnValue -eq 0) { Write-Host "$Computer : Enabled RDP Successfully" "$Computer : RDP Enabled Successfully" } else { Write-Host "$Computer : Failed to enabled RDP" "$Computer : Failed to enable RDP" } } } else {Write-Host "terminal Server on $Computer already Enabled" -BackgroundColor Black -ForegroundColor Green } } |
Enjoy !
Hi, thank you for this great article!
i have a couple of questions if i may –
1. what is the difference between
$RDPStatus.SetAllowTsConnections(1,1)
and $RDPStatus.SessionBrokerDrainMode = 0 ?
2. when i change drain mode using wmi – it does not reflect in the server manager… do you have this issue as well?
thanks again,
Sean