Solved

Close open files and RDP Session

Posted on 2014-02-17
10
771 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
  • 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
 

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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Restoring deleted objects in Active Directory has been a standard feature in Active Directory for many years, yet some admins may not know what is available.
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now