PS Script for Logging Off
-
Tuesday, May 22, 2012 4:02 PM
Due to some mishaps from time to time, is there a simple PowerShell script to log off of one's computer (or, in the sense of remoting in, logging off a remote computer). For instance, in PowerShell the script for restarting the computer isrestart-computer
Is there a simple command to log off a computer?
All Replies
-
Tuesday, May 22, 2012 6:36 PM
Due to some mishaps from time to time, is there a simple PowerShell script to log off of one's computer (or, in the sense of remoting in, logging off a remote computer). For instance, in PowerShell the script for restarting the computer is
restart-computer
Is there a simple command to log off a computer?Try using the logoff executable. Here is the documentation for it:
PS C:\> cmd /c logoff/? Terminates a session. LOGOFF [sessionname | sessionid] [/SERVER:servername] [/V] sessionname The name of the session. sessionid The ID of the session. /SERVER:servername Specifies the Terminal server containing the user session to log off (default is current). /V Displays information about the actions performed. PS C:\>
If you type this command from the powershell console, you might have to follow it with an exit command to avoid finding out that the console needs to be closed:
PS C:\> logoff;exit
Al Dunbar
- Proposed As Answer by Karl Mitschke Tuesday, May 22, 2012 9:27 PM
- Marked As Answer by Yan Li_Microsoft Contingent Staff, Moderator Monday, May 28, 2012 2:12 AM

