The result of Get-Process -Name explorer | select Handles,WS,CPU,Id,ProcessName | ft -HideTableHeaders returns the following output:
2623 255336448 178.125 10080 explorer
Run Code Online (Sandbox Code Playgroud)
In order to ingest this data into a third party system, I need to pipe delimit the result as such:
2623|255336448|178.125|10080|explorer
Run Code Online (Sandbox Code Playgroud)
What is the best way to achieve this?
How about:
(Get-Process explorer |
Select-Object Handles,Ws,CPU,ID,ProcessName |
ConvertTo-Csv -Delimiter '|' -NoTypeInformation |
Select-Object -Skip 1) -replace '"',''
Run Code Online (Sandbox Code Playgroud)
Only use ft (Format-Table) for easy viewing in the PowerShell console (it's not good for sending data to other applications, because then you would have to undo the formatting - so don't format in the first place).
| 归档时间: |
|
| 查看次数: |
1933 次 |
| 最近记录: |