Split text by columns in PowerShell

后端 未结 12 2119
猫巷女王i
猫巷女王i 2020-11-28 15:37

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

12条回答
  •  时光说笑
    2020-11-28 16:01

    a simple way

    get list of active users only

    $logonusers = qwinsta /server:ts33 | Out-String -Stream | Select-String "Active"
    

    clears all the info up apart from the users, with -replace command

    $logonusers = $logonusers -replace("rdp-tcp") -replace("Active") -
    replace("rdpwd") -replace("#") -replace '\s+', ' ' -replace '[0-9]',' '
    
    $logonusers
    

    will then list all the active users.

提交回复
热议问题