簡體   English   中英

如何使用Power Shell從命令輸出中提取值

[英]How to use power shell to exctract values from command output

我正在嘗試通過使用arcconf cli和power shell進行監視來獲取Adaptec raid陣列狀態。 無法找出從Power Shell中的命令返回字符串中獲取最后一個值的方法。

PS C:\adaptec\msm\cmdline> .\arcconf.exe  getconfig  1  | select-string   -pattern "Defunct disk drive count"

   Defunct disk drive count                 : 0

我需要從命令輸出中獲取0值。

將結果拆分到角色':'上,並進行第二部分。 就像是

((.\arcconf.exe getconfig 1 | select-string -pattern "Defunct disk drive count") -split ':')[1]

嘗試這個:

(.\arcconf.exe getconfig 1) -match 'defunct disk drive count\s+:\s+(\d+)'
$matches[1]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM