Enable RDP (Remote Desktop Protocol) using WMI remotely

Your ads will be inserted here by

Easy Plugin for AdSense.

Please go to the plugin admin page to
Paste your ad code OR
Suppress this ad slot.

This allows you to enable Remote Desktop remotely and add a Domain User to the Remote Desktop Users local group.

'Make sure to replace "/" with your Domain name.
 
Const ENABLE_CONNECTIONS = 1
Dim PCName, UsrName
strComputer = InputBox("Enter computer name:",PCName)
strUser = InputBox("Type username:",UsrName)
Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}\\" & strComputer & "\root\cimv2")
 
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_TerminalServiceSetting")
 
For Each objItem in colItems
    errResult = objItem.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next
Set objGroup = GetObject("WinNT://" & strComputer & "/Remote Desktop Users")
Set objUser = GetObject("WinNT:///" & strUser)
objGroup.Add(objUser.ADsPath)
For Each objUser in objGroup.Members
    If objUser.Name = strUser Then
        Wscript.Echo strUser & " has RDP Access to computer."
    End If
Next

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.