pauledwardian
asked on
Powershell to Logoff terminal session
I need a powershell script that would log off a specific user from the terminal server. Can someone please help...
There is a powershell module you can get http://archive.msdn.microsoft.com/PSTerminalServices
but what I have above will work as is with no additional downloads or installs.
but what I have above will work as is with no additional downloads or installs.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks
$sessions = qwinsta /server servername
foreach ($session in $Sessions)
{
#do a split for the values returned which are fixed and assign a variable to it
I can code that if you want me to
Then an if statement if they match e.g.
if ($newvariable -like "*username*")
{
#run rwinsta and disconnect the session by session id which you get from the previous
}
There are many other ways but this is a quick and dirty idea, if you want an actual complete script let me know.