中国诗词大全JSON版:数据结构、加载与避坑实战指南
2026/10/14 14:20:18
在PowerShell中,可以使用Add-Member命令为对象添加新属性。例如,为进程对象添加LifeTimeCpu属性:
Get-Process| where-object {$_.product -match “Office”}| add-member -PassThru -memberType scriptproperty -name LifeTimeCpu -value { ($This.cpu/((get-date)-$This.StartTime ).totalSeconds)} | sort-object -Property lifetimeCpu | format-table -autosize -Property name,vm,cpu,@{Label=”Lifetime CPU”; expression={$_.lifetimecpu.toString(“P”)}}执行上述代码后,输出结果如下:
| Name | VM | CPU | Lifetime CPU |
| ---- | ---- | ---- | ---- |
| communicator | 390860800 | 2364.7411585 | 0.27 % |
| WINWORD | 407875584