PoshCode Archive  Artifact [f4075c6ec8]

Artifact f4075c6ec8bed93ebeac542047d3a2fe1132301ef71da93710e703c1b4944e55:

  • File Log-Off-Local-Users.ps1 — part of check-in [3837384533] at 2018-06-10 14:10:58 on branch trunk — Logoff all disconnected local users, inspired by this: http://poshcode.org/3285 (user: LogOffUsers size: 630)

# encoding: ascii
# api: powershell
# title: Log Off Local Users
# description: Logoff all disconnected local users, inspired by this: http://poshcode.org/3285
# version: 0.1
# author: LogOffUsers
# license: CC0
# x-poshcode-id: 6229
# x-archived: 2016-03-29T15:10:14
# x-published: 2016-02-19T21:42:00
#
#
$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
    }
}