Logging off disconnected sessions from multiple servers (PowerShell)

Hi

I need help finishing up a script to remotely log off disconnected users sessions across multiple servers. 

Code so far;

$servers = Get-Content C:\scripts\testservers.txt

$Disconnectedsessions=qwinsta /server:$servers | select-string "Disc"

Foreach ($Session in $DisconnectedSessions)

{

logoff $Session /server:$servers /v

}

Any help would be appricated! 

Thanks,
SilvrCiv

September 11th, 2015 5:19pm

You have to extract the session id and use that in logoff.

Look in repository for pre-written scripts.

Free Windows Admin Tool Kit Click here and download it now
September 11th, 2015 5:43pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics