Triggering Remote Shutdowns, Restarts and Logoffs.txt - Notepad

Triggering Remote Shutdowns, Restarts and Logoffs

The below PowerShell scripts use the WMI win32_operatingsystem class and Win32Shutdown method to shutdown a list of hostnames remotely. The Win32Shutdown() flags are described below.

0 = Log Off
4 = Forced Log Off
1 = Shutdown
5 = Forced Shutdown
2 = Reboot
6 = Forced Reboot
8 = Power Off
12 = Forced Power Off


$computers = Get-Content c:\computers.txt

foreach ($computer in $computers) {

(get-wmiobject -class win32_operatingsystem -ComputerName $computer).Win32Shutdown(1)

}


foreach ($_ in get-content c:\computers.txt) {

(get-wmiobject -class win32_operatingsystem -ComputerName $_).Win32Shutdown(1)

}

Back