# encoding: ascii
# api: powershell
# title: 
# description: Logoff all disconnected local users, inspired by this: http://poshcode.org/3285
# version: 0.1
# license: CC0
# x-poshcode-id: 6228
# x-archived: 2016-08-26T03:48:48
#
#
$UserSessions = query.exe session | Select-Object -Skip 1
foreach ($SessionString in $UserSessions) {
    $Session = $SessionString.Split(" ",[System.StringSplitOptions]::RemoveEmptyEntries) 
    if (($Session[2] -eq "Disc") -and ($Session[0] -ne "services"))   {
        logoff.exe $Session[1] /V
    }
}
