Убиваем неактивные терминальные сессии скриптом.
foreach ($i in qwinsta /server:terminal | select-string "Диск" | where{$_.tostring()}|where{$_ -notlike "*service*"}){$b=$i.tostring().split()|where{$_}|where{$_ -match "^\d+$"};reset session $b /server:terminal}
foreach ($i in qwinsta /server:terminal | select-string "Диск" | where{$_.tostring()}|where{$_ -notlike "*service*"}){$b=$i.tostring().split()|where{$_}|where{$_ -match "^\d+$"};reset session $b /server:terminal}