powershell - 在 PowerShell 输出中插入分隔符
问题描述
结果Get-Process -Name explorer | select Handles,WS,CPU,Id,ProcessName | ft -HideTableHeaders
返回以下输出:
2623 255336448 178.125 10080 explorer
为了将此数据摄取到第三方系统中,我需要像这样对结果进行管道分隔:
2623|255336448|178.125|10080|explorer
实现这一目标的最佳方法是什么?
解决方案
怎么样:
(Get-Process explorer |
Select-Object Handles,Ws,CPU,ID,ProcessName |
ConvertTo-Csv -Delimiter '|' -NoTypeInformation |
Select-Object -Skip 1) -replace '"',''
仅使用ft
( Format-Table
) 以便在 PowerShell 控制台中轻松查看(它不适合将数据发送到其他应用程序,因为那样您将不得不撤消格式化 - 所以首先不要格式化)。
推荐阅读
- javascript - 在 Django Apache 项目中启用 CORS
- linux - 在 docker compose 中启动没有“sleep infinity”命令的远程容器
- google-maps - 无法绘制直线折线颤振谷歌地图
- r - 使用 MatchIt 进行倾向得分匹配。如何将卡尺引入精确的附加规格
- javascript - html 表格必须保留分页后下拉过滤器
- sql - SQL:用连续索引替换不同的(数字)值
- arrays - Mongoose 从数组字段中拉出一个元素并将新元素推送到它被删除的相同索引处
- python - * 不支持的操作数类型:“float”和“NoneType”
- batch-file - 如何从wsl中的Windows批处理文件执行.sh文件
- shell - 我无法缓存:清除,因为 www-data 使用了 var/cache/dev/profiler