![](/img/trans.png)
[英]how do I use the output of a shell command as a conditional value in a recipe
[英]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.