Logoff user session remotely

Logoff user session remotely

I found a useful method to use WMI to logoff remotely a user session (on a workstation for example). It has been tested successfully on a Windows 7 computer.

This WMI method can be found with the following command:


To logoff a user session on a remote computer, we will use the WMI method called Win32Shutdown

The value 4 is used for a forced logoff. The Microsoft article describes the available codes:

Bitmapped set of flags to shut the computer down. To force a command, add the Force flag (4) to the command value. Using Force in conjunction with Shutdown or Reboot on a remote computer immediately shuts down everything (including WMI, COM, and so on), or reboots the remote computer. This results in an indeterminate return value.

  • 0 (0x0) Log Off
  • 4 (0x4) Forced Log Off (0 + 4)
  • 1 (0x1) Shutdown
  • 5 (0x5) Forced Shutdown (1 + 4)
  • 2 (0x2) Reboot
  • 6 (0x6) Forced Reboot (2 + 4)
  • 8 (0x8) Power Off
  • 12 (0xC) Forced Power Off (8 + 4)

My Powershell script categories

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.