如何使用powershell将不同的计数器输送到表中?

如何使用powershell将不同的计数器输送到表中?,powershell,pipe,Powershell,Pipe,在Powershell中,我试图获取进程(winword.exe)的计数器,然后将其放入如下表中: Process Name CPU Usage(%) Memory Usage(KB) winword.exe 20% 234524324 winword.exe 15% 123343443 .... 进程名称CPU使用率(%)内存使用率(KB) winword.exe 20%234524324 winword.exe

在Powershell中,我试图获取进程(winword.exe)的计数器,然后将其放入如下表中:

Process Name CPU Usage(%) Memory Usage(KB) winword.exe 20% 234524324 winword.exe 15% 123343443 .... 进程名称CPU使用率(%)内存使用率(KB) winword.exe 20%234524324 winword.exe 15%123343443 .... 我可以使用get counter\process(winword*)获取计数器。。。但即使在我选择format table时,也会将每个计数器信息显示为一个列表


如何做到这一点?

以下是脚本,它的格式完全符合您的要求:

$a = @{Expression={$_.Name};Label="Process Name";width=15}, `
@{Expression={$_.ID};Label="Process ID";width=15}, `
@{Expression={$_.CPU};Label="CPU Utilization(%)";width=18}, `
@{Expression={$_.VM};Label="Virtual Memory(K)";width=18} 

Get-Process | Format-Table $a
只需将上述内容另存为脚本,然后在Powershell中运行,您将看到如下结果:

Process Name         Process ID CPU Utilization(%)  Virtual Memory(K)
------------         ---------- ------------------  -----------------
chrome                     7080         65.8636222          340889600
chrome                     7668          0.8268053          199081984
chrome                     8512          4.3836281          168914944

您可以修改脚本以添加/删除更多列,并根据需要设置格式

您也可以使用
-hidetableheaders

请发布完整的命令您正在使用什么?