You can try this:
$pc = qwinsta | select-string "Disc" | select-string -notmatch "services"
if ($pc)
{
$pc = ($pc.tostring() -split ' +')[2]
logoff $pc
}
In this way you can logoff each disconnected session:
$pc = qwinsta | select-string "Disc" | select-string -notmatch "services"
if ($pc)
{
$pc| % {
logoff ($_.tostring() -split ' +')[2]
}
}