Quote:
|
Originally Posted by StumpedTechy absentmind.... I have to ask which part of this script is the portion you use to enable remote desktop on the PC. We set each as we roll it out but there usually may be one or 2 that we miss. We don't want to set a GPO but we want to be able to set it if someone has "forgotten" to set it.
If you look at my script below - Its lower on the thread list - I just set one up to allow us to remote desktop in after adding the user in as admin and then removing it from the admin group after we log in as the user. This would be the BEST addition to my script (with your permission of course).
Squashman that beats my company where anything more than a vbs script has to hit the director and sit on his desk for 6 months before it gets addressed. I am still waiting on about 3 projects I placed on his desk 5 months ago. |
Omit this part... all it does is add you to the Remote Desktop User group... which I realized I don't even need since I'm using domain admin account now.
Code:
Set objGroup = GetObject("WinNT://" & strComputer & "/Remote Desktop Users")
Set objNTProvider = GetObject("WinNT:")
Set objUser = objNTProvider.OpenDSObject
("WinNT://" &strDomain& "/" &strUser& "",lcladmin,lcladminpass,1)
objGroup.Add(objUser.ADsPath) You'd have to integrate this code with your own by changing the variables to match yours... strUser would be changed to strUID, etc. You could also hardcode your domain if you're not working with multiple.
I'll put some notes in the script to identify their functions.
Code:
'---Declarations---
Const wbemImpersonationLevelImpersonate = 3
Const wbemAuthenticationLevelPktPrivacy = 6
Const ENABLE_CONNECTIONS = 1
Const DISABLE_CONNECTIONS = 0
strNameSpace = "root\cimv2"
strClass = "Win32_TerminalServiceSetting"
'---Data Input---
strComputer = InputBox
("Target Computer", "Enable Remote Desktop", default, 100, 100)
If strComputer="" Then
WScript.Echo "Terminated due to missing parameter."
WScript.Quit
End If
strDomain = InputBox ("Domain", "Enable Remote Desktop", default, 100, 100)
If strDomain="" Then
WScript.Echo "Terminated due to missing parameter."
WScript.Quit
End If
strUser = InputBox ("Username", "Enable Remote Desktop", default, 100, 100)
If strUser="" Then
WScript.Echo "Terminated due to missing parameter."
WScript.Quit
End If
strPass = InputBox ("Password", "Enable Remote Desktop", default, 100, 100)
If strPass="" Then
WScript.Echo "Terminated due to missing parameter."
WScript.Quit
End If
'---Connect to remote computer with Domain Admin Credentials---
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")
Set objSWbemServices = objSWbemLocator.ConnectServer _
(strComputer, strNameSpace, strUser, strPass)
objSWbemServices.Security_.ImpersonationLevel =
wbemImpersonationLevelImpersonate
objSWbemServices.Security_.AuthenticationLevel =
wbemAuthenticationLevelPktPrivacy
'---Enable Remote Desktop---
Set colClass = objSWbemServices.ExecQuery("Select * from " & strClass)
For Each objTing in colClass
errAngivelse = objTing.SetAllowTSConnections(ENABLE_CONNECTIONS)
Next
If errAngivelse = 0 THEN
Call MsgBox ("Succesfully enabled on " & strComputer & ". "
, 64, "Enable Remote Desktop")
Else
Call MsgBox ("Could not enable on " & strComputer & ". "
, 64, "Enable Remote Desktop")
End If