1
Vote

pipe work partialy

description

this code work
$ComputerName = 'TSE1.domain.adds'
Get-TSSession -ComputerName $ComputerName | Disconnect-TSSession -ComputerName $ComputerName -Force
but wihtout the parameter -ComputerName on second segment of pipe :
Get-TSSession -ComputerName $ComputerName | Disconnect-TSSession -Force
No error and no work.

same error with Stop-TSSession

comments

omgpirate wrote Feb 10, 2016 at 3:30 PM

I LOVE YOU SCTFIC!

I was going mad! It didn't even cross my mind Stop-TSSession wouldn't work properly without specifying the computer name. For some computers it did, for some it didn't. I grew gray hairs in frustration...

I published an app on RDWeb so every user can fire it and kill their own sessions.
Get-TSSession -ComputerName SERVER01 -UserName $env:username | Stop-TSSession -Force
Get-TSSession -ComputerName SERVER02 -UserName $env:username | Stop-TSSession -Force
It always worked for SERVER02 and logged users correctly out, but never on SERVER01.
Tried re-publishing apps on another node. Didn't help
Double-checked the PowerShell environment and module status. Custom configs. All the same. Didn't help
I thought script may be logging off the session that's supposed to log off all the other sessions. Reversed the order. Didn't help.
Tried about 20 other tricks like running under another user, elevating, creating scheduled task and executing..... Didn't help.

And then I found your issue here, reported almost a year ago and still active. YOUR WORKAROUND HELPED!

I know you most likely forgot about this a long time ago, but I made an account here specifically to say THANK YOU! This was driving me mad!