Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Close open files and RDP Session

Posted on 2014-02-17
10
Medium Priority
?
892 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
Nothing ever in the clear!

This technical paper will help you implement VMware’s VM encryption as well as implement Veeam encryption which together will achieve the nothing ever in the clear goal. If a bad guy steals VMs, backups or traffic they get nothing.

 

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 2000 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

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

It’s been over a month into 2017, and there is already a sophisticated Gmail phishing email making it rounds. New techniques and tactics, have given hackers a way to authentically impersonate your contacts.How it Works The attack works by targeti…
Resolving an irritating Remote Desktop connection that stops your saved credentials from being used.
This tutorial will give a short introduction and overview of Backup Exec 2012 and how to navigate and perform basic functions. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as conne…
This tutorial will walk an individual through setting the global and backup job media overwrite and protection periods in Backup Exec 2012. Log onto the Backup Exec Central Administration Server. Examine the services. If all or most of them are stop…

609 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