title: Get current Windows session ID in PowerShell
body: <p>Every Win32_Process object contains a SessionId field. What is the simplest way to get the current Windows session ID in PowerShell? By current I mean the session in which the script is running. I'd like to avoid parsing the output of the <code>query session</code> command. If that's not achievable, is it possible to list all processes in the current session?</p>