I need a powershell script that would log off a specific user from the terminal server. Can someone please help...
PowershellScripting LanguagesShell Scripting
Last Comment
pauledwardian
8/22/2022 - Mon
becraig
Here is a quick dirty method
$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.
$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.