PSTerminalServices

Hello,

i was just running into an issue with the PSTerminalServices Module.

My target was to logoff a specific client from a Terminal Session. While doing so, everything was fine (unsaved just in editor). But when I saved the script and tried to run it afterwards, the following error occured:

Ausnahme beim Aufrufen von "Logoff" mit 1 Argument(en): "Das System kann die angegebene Datei nicht finden"
In C:\Users\xxx\Documents\WindowsPowerShell\Modules\PSTerminalServices\PSTerminalServices.psm1:631 Zeichen:6
+ $session.Logoff($Synchronous)
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], ParentContainsErrorRecordException
+ FullyQualifiedErrorId : Win32Exception

$client = $env:COMPUTERNAME

Get-TSSession -ComputerName 192.168.45.224| where {$_.ClientName -eq $client} | Stop-TSSession -Force

  1. Does anyone know about this issue? I checked the path, but it is where the .msi installed it to. I also copied it to my win32 path where the v1.0 modules are. When I list all avaible modules it's listed in both module paths.
  2. Is there any other way like with the RemoteDesktop Module?
Kind regards

Sam

So far I changed to RDUserSession…how can i Cast a PSCustomObject to an Int32? The Parsing doesn’t work.

Thanks a lot

$user = $env:USERNAME
$id = Get-RDUserSession -ConnectionBroker server | where {$_.UserName -eq $user} | select {$_.UnifiedSessionId}

$intid = [int]::Parse($id)

Ok get it, no casting necessary.

 

$user = $env:USERNAME
$id = Get-RDUserSession -ConnectionBroker server | where {$_.UserName -eq $user} | select {$_.UnifiedSessionId}

Invoke-RDUserLogoff -HostServer server -UnifiedSessionID $id.'$_.UnifiedSessionId' -Force