# Java 项目实战: 交友项目 - 左滑不喜欢:无配对检查的推荐排除
2026/11/2 6:38:38
在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