# encoding: ascii
# api: powershell
# title: Force current user logof
# description: A simple function to force current user logoff without warning.  The function takes one computer name or a list of computer names.
# version: 0.1
# type: function
# author: lieuhon
# license: CC0
# function: exit-CurrentUser
# x-poshcode-id: 5503
# x-archived: 2015-01-31T20:28:51
# x-published: 2015-10-10T01:37:00
#
# It works on Windows 7 systems in a Active Directory domain.
#
function exit-CurrentUser
{
  <#
    .SYNOPSIS
        Force current logon user logoff; be careful, there is no warning will be given to user!!

    .EXAMPLE
        Exit-CurrentUser -computer com1
  #>
    param (
        [parameter(
            Mandatory = $true,
            ValueFromPipeline=$true)]
        [string[]]
        $computers
    )
    foreach ($computer in $computers) {
        [Void](gwmi -Class Win32_OperatingSystem -ComputerName $computer).Win32Shutdown(4)
    }
}
