Split text by columns in PowerShell

后端 未结 12 2118
猫巷女王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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-28 16:15

    Looks like there are a few answers on this but here's another one.

    You could extract the substring from each line according to the position like this.

    $Sessions=qwinsta.exe
    $SessionCount=$Sessions.count
    [int]$x=1
    do
        {$x++
         if(($Sessions[$x]) -ne $null){$Sessions[$x].subString(19,21).Trim()}
        }until($x -eq $SessionCount)
    

提交回复
热议问题