Help with Users Idle time

Welcome Forums General PowerShell Q&A Help with Users Idle time

Viewing 1 reply thread
  • Author
    Posts
    • #193024
      Participant
      Topics: 1
      Replies: 0
      Points: 14
      Rank: Member

      Hello,

       

      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”

       

    • #193057
      Participant
      Topics: 5
      Replies: 2411
      Points: 6,193
      Helping Hand
      Rank: Community MVP

      If you enclose a number in quotes it’s not a number anymore – it’s a string then. 😉 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? 😉 Now try this:

      [INT]$String1 -gt $String2
Viewing 1 reply thread
  • The topic ‘Help with Users Idle time’ is closed to new replies.