Please use the script to get a list of network adapters which are configured for Remote Desktop Connection and get information of their Settings.
def ExecuteCMD(CMD, OUT = False):
import ctypes
from subprocess import PIPE, Popen
class disable_file_system_redirection:
_disable = ctypes.windll.kernel32.Wow64DisableWow64FsRedirection
_revert = ctypes.windll.kernel32.Wow64RevertWow64FsRedirection
def __enter__(self):
self.old_value = ctypes.c_long()
self.success = self._disable(ctypes.byref(self.old_value))
def __exit__(self, type, value, traceback):
if self.success:
self._revert(self.old_value)
with disable_file_system_redirection():
OBJ = Popen(CMD, shell = True, stdout = PIPE, stderr = PIPE)
out, err = OBJ.communicate()
RET = OBJ.returncode
if not RET:
if OUT:
if out:
return out.strip()
else:
return True
else:
return True
return False
def writeFile(con, ext):
import os
import random
FILEPATH = os.path.join(os.environ['TEMP'], str(random.randint(1, 10000))+ext)
with open(FILEPATH, 'w') as f:
f.write(con)
return FILEPATH
## VBScript for Enumerating IRQ Settings
VBScript=r'''On Error Resume Next
strComputer = "."
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = GetObject("winmgmts:{authenticationLevel=pktPrivacy}!Root/CIMv2/TerminalServices")
Set colSWbemObjectSet = objSWbemServices.InstancesOf("Win32_TSRemoteControlSetting")
For Each objSWbemObject In colSWbemObjectSet
WScript.Echo "Caption: " & objSWbemObject.Caption
Wscript.Echo "Description: " & objSWbemObject.Description
Wscript.Echo "InstallDate: " & objSWbemObject.InstallDate
Wscript.Echo "Name: " & objSWbemObject.Name
Wscript.Echo "Status: " & objSWbemObject.Status
Wscript.Echo "TerminalName: " & objSWbemObject.TerminalName
Wscript.Echo "LevelOfControl: " & objSWbemObject.LevelOfControl
Wscript.Echo "PolicySourceLevelOfControl: " & objSWbemObject.PolicySourceLevelOfControl
Wscript.Echo "RemoteControlPolicy: " & objSWbemObject.RemoteControlPolicy
Wscript.Echo
Next'''
file=writeFile(VBScript, '.vbs')
import os
if os.path.isfile(file):
print ExecuteCMD('cscript "'+file+'"', True)
## cleans up the vbs script file
os.remove(file)
Script File:
20170223-List-Network-Adapters-Configured-for-Remote-Desktop-Connection.json
Sample Output:
20170223-List-Network-Adapters-Configured-for-Remote-Desktop-Connection.json (3.39 KB)