title: Split text by columns in PowerShell
body: <p>I'm a PowerShell novice (Bash is my thing normally) who's currently trying to obtain qwinsta output to show who is logged in as an 'rdpwd' (rdesktop) user so that I can check each username against a list of usernames, and if they do not match, log them off.</p>
  
  <p>I am currently working through two problems:</p>
  
  <ol>
  <li>I am unable to split the qwinsta output to be left with only the username - I've tried the "split" function but so far am getting either syntax issues or weird results; one gripe seems to be that '\s+' matches the letter S instead of whitespace; other times I've managed to split to the second column, but only output from line 1 appears </li>
  <li>Whilst I'm not there yet, I sense that I will have problems with the second step as well, namely looping through the array of non-log-offable users (which are to be obtained from a local user group)</li>
  </ol>
  
  <p>I'll focus on problem 1 for now!</p>
  
  <p>The text I've got is:</p>
  
  <pre><code>SESSIONNAME       USERNAME        ID     STATE   TYPE      DEVICE
  services                          0      Disc
  console                           1      Conn
  rdp-tcp#0         user.name1      2      Active  rdpwd
  rdp-tcp#1         user.name2      3      Active  rdpwd
  rdp-tcp#1         user.name3      4      Active  rdpwd
  rdp-tcp                           65536  Listen
  </code></pre>
  
  <p>The output I want is:</p>
  
  <pre><code>user.name1
  user.name2
  user.name3
  </code></pre>
  
  <p>(With the aim of then creating a loop that says, in brief terms, "foreach user in list, if not in localgroup, logoff user".)</p>
  
  <p>So far, I've got as far as selecting text with 'rdpwd', but using all manner of variations on "split", I have not got further forward than that.</p>
  
  <p>I'm happy to share what I've got already, but alas I don't think it'll help anyone! </p>
  
  <p>Any assistance would be most appreciated. :) </p>