This article explains how to enable RDP on local and multiple remote computers using a simple powershell script, In the remote world we are controlling almost everything related to technology.
There are two ways one can enable the RDP on windows computers, one is using WMI method and other way is registry setting, WMI way is pretty simple to enable the RDP on multiple remote computers.
Enable RDP on local computer.
$enableRDP= Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace Root\CimV2\TerminalServices -ComputerName localhost
$enableRDP.SetAllowTSConnections(0,0)
Powershell Enable RDP on remote computers.
We need to create a file for storing all the servers or multiple machines lists, I named it as Allservers.txt for and saved it in my local machine c:\temp\Allserve.txt
$Allserver = Get-Content -Path "C:\temp\AllServer.txt"
$enableRDP=$null
foreach ($server in $allserver)
{
Write-Host "Currently the script is stopping the serivce on" $server
$enableRDP= Get-WmiObject -Class Win32_TerminalServiceSetting -Namespace Root\CimV2\TerminalServices -ComputerName $server
$enableRDP.SetAllowTSConnections(0,0)
}
The script enables RDP connection on remote multiple remote computers, as i said earlier, using WMI method of enabling RDP is easy than registry way.
The IT admin should have admin rights to execute this script on remote computers, generally, system admins have privilege access to computers, if not one will run into permission or access denied issues, make sure you have admin rights on the remote computers. if you are supporting for large scale enterprise then the above script is useful
Thank you for reading this article, if you have any questions please let us know.
Thank you for visiting my site, for any scripts in these articles you are testing please make sure you have tested this script in our lower environment before you run in production.
Leave a Reply Cancel reply