title: Powershell Log Off Remote Session
body: <p>I am trying to formulate a Powershell command to remotely log off a user. We have a terminal server with a very unstable program that sometimes locks sessions. We have to remotely log off a user but I'm trying to write a Powershell statement that will log off the person who ran the script. I Googled around, and found this command:</p>
  
  <pre><code>Invoke-Command -ComputerName MyServer -Command {shutdown -l}
  </code></pre>
  
  <p>However, the command returns "incorrect function." I can run other commands successfully in the brackets, such as Get-Process.</p>
  
  <p>The idea is for me to put that into a script that users can run to log themselves off of the server (since when it locks, they cannot access the start menu or ALT+CTRL+END to do it through the GUI).</p>
  
  <p>The flow would be this:
  Bob logs into MyServer via RDP but his session freezes. On his local desktop, he can run MyScript (containing a command similar to above) which will log off his session on MyServer.</p>