In situations when you unable to connect to remote WS 2008 box via RDS due to Windows Firewall being enabled without inbound RDS rule enabled you may try to enable required firewall rule remotely.
If PS on machine in question is configured for remoting you may open remote PS session on this machine, using following command:
enter-pssession -computername REMOTE_COMPUTER_NAME
If remote PS session opened successfully you may run both PS commands and regular CLI commands for remote machine there. To check inbound RDS rule for Windows firewall use:
netsh advfirewall firewall show rule name=”Remote Desktop (TCP-IN)”
If this role not enabled issue following command to enable it:
netsh advfirewall firewall set rule name=”Remote Desktop (TCP-IN)” new enable=yes
Starting with Windows Server 2012 you may control Windows Firewall with PS commandlets which is much more convenient and easier.
Apart from obvious ways to do it via Windows Server GUI which is the long way (plus if you working with multiple versions like Server 2003 and 2008 it differs slightly and requires you to remember the “path” through GUI to find this information) there are CLI tool to accomplish this:
qwinsta available starting from Windows XP, if run locally lists RDP connections to local host and alternatively it can do this for remote machines (in the same domain) if run with /server key:
Output of this command gives you list of users connected to server along with their session ID, which you can use to disconnect sessions via command line with help of the second tool rwinsta which can be used with following syntax:
rwinsta /server:%SERVERNAME% %SESSION_ID%
Note on etimology of those commands:
qwinsta stands for Query WINdows STAntion
rwinsta stands for Reset WINdows STAntion
Starting from Windows Server 2003 you can also use query session command for the same purpose.
To add all known RDS license servers to specified license servers list you could use RDS Host Configuration console (tsconfig.msc), but in Windows Server 2008 R2 GUI doesn’t allow for multiple select and therefore if you need to add all known license servers via GUI it is a little bit inconvenient.
Better option to accomplish this is via PowerShell, here is how:
\n[code lang=”powershell”]\nimport-module remotedesktopservices\ncd RDS:RDSConfigurationLicensingSettingsSpecifiedLicenseServers\ndir ..RegisteredLicenseServers | new-item -force</blockquote>\n[/code]
And as you most likely going to do it remotely you should use Enter-PSSession -ComputerName YOUR_SERVER_NAME to start remote PS session. In case PSRemoting is not enabled (use Test-WSMan to check) go to target machine and use Enable-PSRemoting – force to enable it.