PoshCode Archive  Artifact [8c28194d2d]

Artifact 8c28194d2d29f97e99ada0e4aef541f296e602f2391578ddac42e6a8919dd4b8:

  • File Logoff-all-disconnected-local-users-.ps1 — part of check-in [b4d9f6178a] at 2018-06-10 14:10:57 on branch trunk — Logoff all disconnected local users, inspired by this: http://poshcode.org/3285 (user: unknown size: 554)

# 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
    }
}