Powershell - Session Disc not found


I am using the following command to kick a user out of their session on a Terminal Server:

Logoff $id /server:$serverName

Where $id is their session id and $serverName is the name of the server. I can see their session with this command:

query user /server:$serverName

Where $serverName is the name of the server. When I call Logoff, I am occasionally getting this message:

Session Disc not found

And the user is not kicked out. I would expect that given the session ID they would be kicked out. Why is this not happening?

- - Source
comments powered by Disqus