Solved

Close open files and RDP Session

Posted on 2014-02-17
10
814 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
Technology Partners: 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!

 

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Remote Apps is a feature in server 2008 which allows users to run applications off Remote Desktop Servers without having to log into them to run the applications.  The user can either have a desktop shortcut installed or go through the web portal to…
A procedure for exporting installed hotfix details of remote computers using powershell
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

749 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