Help with Users Idle time



I am using quser to find the idle time of users on a terminal server, I need to filter anyone idled longer than 10 minutes.


With this, use the username to find all processes name PROCESSexample.exe and force close the process. So far I am getting stuck on the system.string with the output not being a int for idle time.


$userName = ‘*’
$computer = ‘localhost’
$quserResult = quser /server:$computer 2>&1
$quserRegex = $quserResult | ForEach-Object -Process { $_ -replace ‘\s{2,}’,‘,’ }
$quserObject = $quserRegex | ConvertFrom-Csv
$Result = $quserobject | where “Idle time” -ge “10”


If you enclose a number in quotes it’s not a number anymore - it’s a string then. :wink: If you have string and want to convert it to a (integer) number you can cast it to with [INT]“your number” …

$String1 = "8"
$String2 = 20
$String1 -gt $String2

What would you expect will be the result of this comparison? :wink: Now try this:

[INT]$String1 -gt $String2