Solved

Close open files and RDP Session

Posted on 2014-02-17
10
835 Views
Last Modified: 2014-02-18
I need some help in setting up a scheduled task that will log off all users from a terminal server and close any and all open files.  I have users disconnecting instead of logging off of the the server and this is causing and index function that runs as a scheduled task to fail every night.  I have tried to get tslogoff.exe to work but with no success on a 2008 R2 server.  I do not know how to add cmdlets to Powershell or even how to get a script to run correctly.  I have downloaded handle.exe from sysinternals but do not know what i need to do to get the cmdlets installed and create a script to log off the users that disconnected and close the open files.  I know this should be easy but i am not having any success and need assistance please.
I have tried to follow this article but i must be missing something.
http://www.experts-exchange.com/Microsoft/Applications/Q_27494075.html
0
Comment
Question by:digitalsoup
[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
  • 5
  • 4
10 Comments
 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39865594
Hi,

Why you simple dont use built in policy? You can setup idle time for user and after idle time disconect user and then time he can reconect and after this time is reached hes sesion will be ended.

We have this 30 a 30 minutes becouse sometimes its auto update what disconect sesion

http://www.ryanbelanger.com/remote-desktop-session-automatic-logoff-on-windows-2008-r2/
0
 
LVL 2

Expert Comment

by:Sylvain_piv
ID: 39865672
Yes make a policy.

Or if you want you can do that on the tscc.msc console on the tcp properties.
0
 

Author Comment

by:digitalsoup
ID: 39865859
I cannot afford to simply boot a disconnected user.  I need to close the files and applications that are open in order to prevent data corruption.  We need a process that closes the open files and connections for disconnected or even logged in users.  If i simply "End Task" i get lots of errors in the index records.  I need a powershell script to do this and i know it is supported i just can't figure out how to make it happen.
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:digitalsoup
ID: 39865984
can someone please help me to get handle.exe running and registered in powershell?  Does it require version 2 or higher?
0
 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39866058
To manage ts from powershel you can use http://code.msdn.microsoft.com /PSTerminalServices
0
 
LVL 15

Accepted Solution

by:
Jaroslav Mraz earned 500 total points
ID: 39866061
0
 

Author Comment

by:digitalsoup
ID: 39866093
now that put me in the right direction.  I got psterminalservices module loaded.  Now i need to write the script to log off any/all users so that i can schedule it.  I am running powershell v2.0
0
 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39866187
The example you need is on website



# Logs off all the active sessions from remote computer 'comp1', no confirmations
PS > Get-TSSession -ComputerName comp1 -State Active | Stop-TSSession –Force


Without force you manualy need to confirm
0
 
LVL 15

Expert Comment

by:Jaroslav Mraz
ID: 39866189
Comp1 can be server name or localhost
0
 

Author Closing Comment

by:digitalsoup
ID: 39867472
Thank you for assisting me with this process.  It works great now.
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

717 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