我正在使用以下命令根據虛擬記憶體利用率對行程進行排序:
PS C:\Windows\system32> Get-Process | Sort PagedMemorySize64 -Desc | Select Id, Name, PagedMemorySize64 , VirtualMemorySize64 -First 10 |sls jqlserver
@{Id=37724; Name=jqlserver; PagedMemorySize64=3147898880; VirtualMemorySize64=27032002560}
我的問題是如何將 PID 值 37724 提取到變數 $PID1 中。我在Powershell中嘗試了很多決議陣列的東西,不知何故我無法得到它。你能給我一個想法嗎?
謝謝
uj5u.com熱心網友回復:
似乎您只對jqlserver行程感興趣,在這種情況下,您不需要使用Select-String( sls),PowerShell cmdlet 通常會輸出物件并且無需決議它們:
$process = Get-Process -Name jqlserver | Sort-Object PagedMemorySize64 -Descending |
Select-Object Id, Name, PagedMemorySize64, VirtualMemorySize64 -First 10
$pid1 = $process[0].Id
$process[0]在上面的示例中,參考生成的物件陣列( )的第一個元素(索引 0 - 參見about_Arrays ),然后參考屬性并獲取它的值。object[]Get-Process.IdId
有關更多有用資訊,請參閱about_Properties。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/428280.html
標籤:电源外壳
上一篇:輸入在腳本塊內更改
