1. You need to get the session ID of a user to log off by running the following command:
qwinsta /server:servername
2. Enter the following command with the session ID at the end to log the user of:
logoff /server:servername (session id)
I used these commands to put together the following script. It will prompt you for the server name and give you the output of current open sessions then prompt you for the session ID to log off. Enjoy:
$server = read-host "Hostname"
qwinsta /server:$server
$ID = read-host "Session ID to log off"
logoff /server:$server $ID
No comments:
Post a Comment