I rewrote this, but I have not tested the full script, and it is not optimized. If you encounter any problems, feel free to contact me.
$statuses = @() $servers = get-content "c:\list.txt" $splitter = [regex]"\s+" foreach ($server in $servers) { $command = "quser /server:$server" $lines = @((invoke-expression $command | Out-String) -split "`n")
source share