taliesins / cassia

Automatically exported from code.google.com/p/cassia
1 stars 0 forks source link

cannot use the Stop-TSSesion -force on disconnected session #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
I am trying to find all disconnected Terminal server session to generate a 
report. Then i want to disconect them with:

My report before:
ServerName: ! SYST460
UserName id        State IdleTime           LoginTime          
-------- --        ----- --------           ---------          
            Disconnected 00:00:00                              
admin456     Disconnected 5.18:23:32.0590000 2012/12/10 03:35:40
admin123     Disconnected 4.14:23:32.4250000 2012/12/12 09:39:09

get-TSSession -ComputerName $currline  -State Disconnected | Stop-TSSession 
–Force

But i get:

ServerName: ! SYST460 = windows 2008 R2
Exception calling "Logoff" with "1" argument(s): "Access is denied"
 à C:\Documents and Settings\myaccount\My Documents\WindowsPowerShell\Modules\PSTerminalServices\PSTerminalServices.psm1: ligne:631 caractère:21
+                   $session.Logoff( <<<< $Synchronous)

Here with another situation: 
This server was down but the script stops because i get this:

ServerName: ! SYST934
Exception calling "Open" with "0" argument(s): "The RPC server is unavailable"
 à C:\Documents and Settings\myaccount\My Documents\WindowsPowerShell\Modules\PSTerminalServices\PSTerminalServices.psm1: ligne:189 caractère:24
+           $TSRemoteServer.Open( <<<< )    

What version of Cassia are you using (e.g. 2.0.0.60)? Yes

On what Windows version is your code running?
I run it from my PC = windowx xp 

Original issue reported on code.google.com by flau...@gmail.com on 18 Dec 2012 at 9:03

GoogleCodeExporter commented 9 years ago
Regarding your first issue: It looks like you have a disconnected session 
without a username. This could be the services session (session 0) or another 
system session that it wouldn't make sense to log off. Try skipping sessions 
like that in your script, or catch and discard the exception that is thrown.

Regarding your second issue: That error ("The RPC server is unavailable") is 
the one you would expect when trying to connect to a server that is down. You'd 
need to catch and handle that exception.

Original comment by danports on 28 Dec 2012 at 2:37