Log all users out of a Windows System with Powershell

$users=(c:\windows\system32\query.exe user)                                                            
$users | select -Skip 1 {
	$f=($users[2].Split() | ? {$_})  
	$n=$f[2]                                                                                                   
	if($n -eq "Disc") { $n=$f[1] }                                       
	if($n -match '^\d+$') { & C:\Windows\System32\logoff.exe $n }        
}      

0 thoughts on “Log all users out of a Windows System with Powershell

Leave a Reply

Your email address will not be published. Required fields are marked *