我正在尝试编写一个 Powershell 脚本以从 HP RAID 控制器获取状态(使用hpssacli.exe ctrl slot=1 ld all show detail
并将其通过管道传输到文件中。
我只需要检查是否Status: OK
出现在输出中。问题是有多个字符串包含Status: OK
输出.txt
Smart Array P410 in Slot 1
array A
Logical Drive: 1
Size: 10.9 TB
Fault Tolerance: 5
Heads: 255
Sectors Per Track: 32
Cylinders: 65535
Strip Size: 256 KB
Full Stripe Size: 1024 KB
Status: Interim Recovery Mode
Caching: Enabled
Parity Initialization Status: Initialization Completed
Disk Name: /dev/sda
Mount Points: /storage 10.9 TB Partition Number 2
OS Status: LOCKED
Drive Type: Data
LD Acceleration Method: Controller Cache
我试图运行该命令sls "Status: " .\output.txt
,但收到 3 个匹配项:
output.txt:13: Status: Interim Recovery Mode
output.txt:15: Parity Initialization Status: Initialization Completed
output.txt:19: OS Status: LOCKED
Powershell有没有办法进行正则表达式样式匹配以仅匹配字符串不是字符的位置,然后是Status:
?