Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1188
  • Last Modified:

Need to configure RDP timeout value using VBScript.

Hi All,

Could u pls help me to configure RDP timeout value using VBScript as mentioned in the attached screenshot.
 .
I have attached screenshot for windows server 2003 and windows server 2008.

Any assistance could offer would be greatly appreciated as i need to manually configure the 127 servers.

If anyone knows, please create separate scripts for windows 2003 and windows 2008.
 RDP Timeout value for windows server 2003 RDP Timeout value for windows server 2008
0
jashir101
Asked:
jashir101
  • 15
  • 11
  • 4
1 Solution
 
mustang83Commented:
Create a group policy that covers all servers in active directory. You can set the default timeout sessions for RDP their.

http://technet.microsoft.com/en-us/library/cc753112(WS.10).aspx

0
 
jashir101Author Commented:
Thanks for your reply mustang83.

Is there any way to create script for this??

0
 
mustang83Commented:
Not that i know off. Due to it being so easy in group policy.

Ive had a quick google around but always fall on group policy which is way i would do it.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
jashir101Author Commented:
Group policy means how can we do that?

Can u pls provide step by step procedure.
 
I know the steps how to manually configure to change RDP timeout value. But it takes time as i need to manually change 127 servers
0
 
mustang83Commented:
1.Go to you domain controller
2. Open group policy management
3. Go to the parent OU of all your servers
4.Right click and select create and link new group policy
5.navigate in the policy to (if DC is 2003) : Computer Configuration > Administrative Templates > Windows Components > Terminal Services > Sessions,
5.navigate in the policy to (if DC is 2008) : Computer Configuration > Policies > Administrative Templates > Windows Components > Remote Desktop Services > Remote Desktop Session Host > Session Time Limits

6.enable the settings you want to configure.

That should do the trick.
0
 
jashir101Author Commented:
hi mustang83,

We dont have access to DC servers.
0
 
mustang83Commented:
do you have access to group policy management?

It can be on a management server or your pc? If not ask your domain admin to do this for you.
0
 
chakkoCommented:
Try this script.



strComputer = "."
 


   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_TSSessionSetting")

   For Each objItem In colItems
     if objItem.TerminalName = "RDP-Tcp" then
        objItem.TimeLimitPolicy = 0             'ENABLES Connection Override for Time Settings
        objItem.Put_                    'Commits the override so other settings will go through without error
        objItem.TimeLimit "DisconnectedSessionLimit", 60000       'Disconnected for 1 Min
        objItem.TimeLimit "ActiveSessionLimit", 3600000           'Active for 1 Hour
      objItem.TimeLimit "IdleSessionLimit", 600000
        objItem.Put_
        objItem.Refresh_
        objItem.BrokenConnectionPolicy = 0                         'ENABLES Connection Override for Broken Connections
        objItem.Put_
      objItem.BrokenConnection 1             'ENDS Broken Connections
        objItem.ReconnectionPolicy = 0          'ENABLES Connection Override for Reconnecting Sessions
       objItem.Put_
     end if
   Next
0
 
jashir101Author Commented:
im getting error while trying to run the above script.

Attaching screenshot here. error
0
 
chakkoCommented:
The script from before is for Windows 2003.

Here is the adjusted one for 2008


strComputer = "."
 


   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\TerminalServices")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_TSSessionSetting")

   For Each objItem In colItems
     if objItem.TerminalName = "RDP-Tcp" then
        objItem.TimeLimitPolicy = 0             'ENABLES Connection Override for Time Settings
        objItem.Put_                    'Commits the override so other settings will go through without error
        objItem.TimeLimit "DisconnectedSessionLimit", 60000       'Disconnected for 1 Min
        objItem.TimeLimit "ActiveSessionLimit", 3600000           'Active for 1 Hour
        objItem.TimeLimit "IdleSessionLimit", 600000
        objItem.Put_
        objItem.Refresh_
        objItem.BrokenConnectionPolicy = 0                         'ENABLES Connection Override for Broken Connections
        objItem.Put_
        objItem.BrokenConnection 1             'ENDS Broken Connections
        objItem.ReconnectionPolicy = 0          'ENABLES Connection Override for Reconnecting Sessions
        objItem.Put_
     end if
  Next
0
 
jashir101Author Commented:
Excellent Chakko

The script is working fine on windows server 2008.
However i want ActiveSessionLimit should be set to never not for 1 hour.
Can u pls help on that??          

What abt windows server 2003??
0
 
chakkoCommented:
Win 2008:

strComputer = "."
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\TerminalServices")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_TSSessionSetting")
   For Each objItem In colItems
     if objItem.TerminalName = "RDP-Tcp" then
        objItem.TimeLimitPolicy = 0             'ENABLES Connection Override for Time Settings
        objItem.Put_                    'Commits the override so other settings will go through without error
        objItem.TimeLimit "DisconnectedSessionLimit", 60000       'Disconnected for 1 Min
        objItem.TimeLimit "ActiveSessionLimit", 0           'Never
        objItem.TimeLimit "IdleSessionLimit", 600000      '10 minutes
        objItem.Put_
        objItem.Refresh_
        objItem.BrokenConnectionPolicy = 0                         'ENABLES Connection Override for Broken Connections
        objItem.Put_
        objItem.BrokenConnection 1             'ENDS Broken Connections
        objItem.ReconnectionPolicy = 0          'ENABLES Connection Override for Reconnecting Sessions
        objItem.Put_
     end if
  Next


Win 2003:



strComputer = "."
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_TSSessionSetting")
   For Each objItem In colItems
     if objItem.TerminalName = "RDP-Tcp" then
        objItem.TimeLimitPolicy = 0             'ENABLES Connection Override for Time Settings
        objItem.Put_                    'Commits the override so other settings will go through without error
        objItem.TimeLimit "DisconnectedSessionLimit", 60000       'Disconnected for 1 Min
        objItem.TimeLimit "ActiveSessionLimit", 0          'Never
        objItem.TimeLimit "IdleSessionLimit", 600000       ' 10 Minutes
        objItem.Put_
        objItem.Refresh_
        objItem.BrokenConnectionPolicy = 0                         'ENABLES Connection Override for Broken Connections
        objItem.Put_
        objItem.BrokenConnection 1             'ENDS Broken Connections
        objItem.ReconnectionPolicy = 0          'ENABLES Connection Override for Reconnecting Sessions
        objItem.Put_
     end if
   Next

0
 
jashir101Author Commented:
Thanks Chakko.

It is working fine win 2008 std edition 32 bit.

Howver it is not working on win 2008 ent edition 64 bit.I believe it is due to some group policy. Please see the below screenshot.

I havent tested for win 2003.
Please help me on this. win 2008 ent edition 64 bit
0
 
jashir101Author Commented:
I have tested on win 2003.

Its not working..attaching screenshot here. win 2003
0
 
chakkoCommented:
Did you make 2 scripts. I posted 2 in my last message.  Win 2008:  and Win 2003:    Those are 2 separate scripts.   Don't copy the line with the label ( Win 2008 or Win 2003).
0
 
jashir101Author Commented:
i executed 2 separate scripts for win 2003 and win 2008..

it s working well on win 2008 32 bit std edition.

Please check on this
0
 
chakkoCommented:
I have tested it on Windows 2003 standard, Windows 2008 (32bit and 64bit).  No errors on my machines.

please try this.  Attached scripts


2k3.vbs.vbs
2k8.vbs.vbs
0
 
jashir101Author Commented:
Chakko, still im getting same error for win 2008
Capture.JPG
0
 
chakkoCommented:
It works fine on my servers so I'm not sure how to debug any further without being able to see the problem for myself.

try this for windows 2008.  maybe get lucky.

have you tried on other machines also?  maybe 1 server just has some problem?

strComputer = "."
   Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2\TerminalServices")
   Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_TSSessionSetting",,48)
   For Each objItem In colItems
     if objItem.TerminalName = "RDP-Tcp" then
        objItem.TimeLimitPolicy = 0          
        objItem.Put_                    
      objItem.Refresh_
        objItem.TimeLimit "DisconnectedSessionLimit", 60000    
        objItem.TimeLimit "ActiveSessionLimit", 0          
        objItem.TimeLimit "IdleSessionLimit", 600000    
        objItem.Put_
        objItem.Refresh_
        objItem.BrokenConnectionPolicy = 0                        
        objItem.Put_
        objItem.BrokenConnection 1          
        objItem.ReconnectionPolicy = 0        
        objItem.Put_
     end if
  Next
0
 
jashir101Author Commented:
sorry to interrupt u chakko..still im getting error..

ill try other machines by monday...

thanks for ur help..god bless u.. win 2008
0
 
jashir101Author Commented:
can u give me ur instant messenger id??
0
 
chakkoCommented:
Please try some other machines first and maybe those will be Ok

I can add some error checking code, but it shouldn't require it.  
0
 
jashir101Author Commented:
Sorry for the late reply chakko. Still im getting same error.

I guess its due to some group policy...
0
 
chakkoCommented:
It could be.  I have tried it on another 2008 SBS server and an SBS 2011 server and no error popup.
0
 
chakkoCommented:
Try this one.  It should show some info about any error.
2k8.vbs
0
 
jashir101Author Commented:
Please see the below screenshots while trying to execute the script. error error1 error2 error3
0
 
chakkoCommented:
Try this one.  Let me know if it mentions a popup message about a Policy.
2k8.vbs
0
 
jashir101Author Commented:
this time i couldnt get any error. and but it still remains the same means it didnt change RDP timeout value. error
0
 
chakkoCommented:
Yes, it has a setting to ignore an error, so that result message is actually not correct.

It seems to be failing on the DisconnectedSession Timeout value.  It works on other servers so please take a look on your side.

Have you tried the script on other servers?
0
 
jashir101Author Commented:
Thanks for spending time with me Chakko.

Ill try other machines tomorrow.

Meanwhile I have raised another incident.

ID: 27383759

Title: Adding workgroup computer (Windows Server 2003 and Windows 2008) to domain using vbscript.

Please look into it.
0

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 15
  • 11
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now