I'm trying to write a script that'll find all TS sessions our administrators have disconnected from and kill them. But I can't seem to get stop-tssession to work properly. Am I missing something obvious?
Thanks,
Greg
> Get-TSSession -ComputerName corphv14 -State Disconnected -Username *admin
Server SessionID State IPAddress ClientName WindowStationName UserName
------ --------- ----- --------- ---------- ----------------- --------
corphv14 2 Disconnected
CORP\mmadmin
> Get-TSSession -ComputerName corphv14 -State Disconnected -Username *admin | Stop-TSSession -Force
> Get-TSSession -ComputerName corphv14 -State Disconnected -Username *admin
Server SessionID State IPAddress ClientName WindowStationName UserName
------ --------- ----- --------- ---------- ----------------- --------
corphv14 2 Disconnected
CORP\mmadmin