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
I wrote a reusable ConvertFrom-SourceTable cmdlet which is available for download at the PowerShell Gallery and the source code from the GitHub iRon7/ConvertFrom-SourceTable repository.
$Object = ConvertFrom-SourceTable '
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
'
It pretty flexible and capable of reading a lot of table format including reading the output of the results. Or even if e.g. the ID column is right aligned meaning that it would concern integers rather than strings:
$Object = ConvertFrom-SourceTable '
ID TYPE USERNAME STATE DEVICE SESSIONNAME
-- ---- -------- ----- ------ -----------
0 Disc services
1 Conn console
2 rdpwd user.name1 Active rdp-tcp#0
3 rdpwd user.name2 Active rdp-tcp#1
4 rdpwd user.name3 Active rdp-tcp#1
65536 Listen rdp-tcp
'
For details see: ConvertFrom-SourceTable -?