Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Need to configure RDP timeout value using VBScript.

Posted on 2011-09-27
30
Medium Priority
?
1,172 Views
Last Modified: 2012-05-12
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
Comment
Question by:jashir101
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 15
  • 11
  • 4
30 Comments
 
LVL 4

Expert Comment

by:mustang83
ID: 36708378
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
 

Author Comment

by:jashir101
ID: 36708829
Thanks for your reply mustang83.

Is there any way to create script for this??

0
 
LVL 4

Expert Comment

by:mustang83
ID: 36708876
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
Office 365 Training for Admins - 7 Day Trial

Learn how to provision tenants, synchronize on-premise Active Directory, implement Single Sign-On, customize Office deployment, and protect your organization with eDiscovery and DLP policies.  Only from Platform Scholar.

 

Author Comment

by:jashir101
ID: 36709024
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
 
LVL 4

Expert Comment

by:mustang83
ID: 36709532
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
 

Author Comment

by:jashir101
ID: 36709988
hi mustang83,

We dont have access to DC servers.
0
 
LVL 4

Expert Comment

by:mustang83
ID: 36710554
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
 
LVL 22

Expert Comment

by:chakko
ID: 36890443
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
 

Author Comment

by:jashir101
ID: 36890920
im getting error while trying to run the above script.

Attaching screenshot here. error
0
 
LVL 22

Expert Comment

by:chakko
ID: 36891377
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
 

Author Comment

by:jashir101
ID: 36892582
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
 
LVL 22

Expert Comment

by:chakko
ID: 36894657
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
 

Author Comment

by:jashir101
ID: 36895433
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
 

Author Comment

by:jashir101
ID: 36895444
I have tested on win 2003.

Its not working..attaching screenshot here. win 2003
0
 
LVL 22

Expert Comment

by:chakko
ID: 36895468
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
 

Author Comment

by:jashir101
ID: 36895525
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
 
LVL 22

Accepted Solution

by:
chakko earned 2000 total points
ID: 36895551
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
 

Author Comment

by:jashir101
ID: 36895617
Chakko, still im getting same error for win 2008
Capture.JPG
0
 
LVL 22

Expert Comment

by:chakko
ID: 36895628
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
 

Author Comment

by:jashir101
ID: 36895639
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
 

Author Comment

by:jashir101
ID: 36895641
can u give me ur instant messenger id??
0
 
LVL 22

Expert Comment

by:chakko
ID: 36895649
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
 

Author Comment

by:jashir101
ID: 36922561
Sorry for the late reply chakko. Still im getting same error.

I guess its due to some group policy...
0
 
LVL 22

Expert Comment

by:chakko
ID: 36922594
It could be.  I have tried it on another 2008 SBS server and an SBS 2011 server and no error popup.
0
 
LVL 22

Expert Comment

by:chakko
ID: 36922608
Try this one.  It should show some info about any error.
2k8.vbs
0
 

Author Comment

by:jashir101
ID: 36922751
Please see the below screenshots while trying to execute the script. error error1 error2 error3
0
 
LVL 22

Expert Comment

by:chakko
ID: 36922839
Try this one.  Let me know if it mentions a popup message about a Policy.
2k8.vbs
0
 

Author Comment

by:jashir101
ID: 36923189
this time i couldnt get any error. and but it still remains the same means it didnt change RDP timeout value. error
0
 
LVL 22

Expert Comment

by:chakko
ID: 36923261
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
 

Author Comment

by:jashir101
ID: 36925223
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will show how to push an installation of Backup Exec to an additional server in both 2012 and 2014 versions of the software. Click on the Backup Exec button in the upper left corner. From here, select Installation and Licensing, then I…
This tutorial will walk an individual through locating and launching the BEUtility application to properly change the service account username and\or password in situation where it may be necessary or where the password has been inadvertently change…
Suggested Courses

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question