问题描述
在使MegaCli命令的输出更具可读性方面寻求帮助。
输出为:
PS C:\Users\Administrator> C:\Users\Administrator\Downloads\8-04-07_MegaCLI\Win_CliKL_8.04.07\MegaCliKL -LDInfo -Lall -aAll
Adapter 0 -- Virtual Drive information:
Virtual Drive: 0 (Target Id: 0)
Name :OS
RAID Level : Primary-1,Secondary-0,RAID Level Qualifier-0
Size : 558.375 GB
Mirror Data : 558.375 GB
State : Optimal
Strip Size : 64 KB
Number Of Drives : 2
Span Depth : 1
Default Cache Policy: WriteBack,ReadAdaptive,Direct,No Write Cache if Bad BBU
Current Cache Policy: WriteBack,No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
disk Cache Policy : disk's Default
Encryption Type : None
Bad Blocks Exist: No
Is VD Cached: Yes
Cache Cade Type : Read Only
Virtual Drive: 1 (Target Id: 1)
Name :Storage
RAID Level : Primary-0,RAID Level Qualifier-0
Size : 7.275 TB
Parity Size : 0
State : Optimal
Strip Size : 64 KB
Number Of Drives : 4
Span Depth : 1
Default Cache Policy: WriteBack,No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
disk Cache Policy : disk's Default
Encryption Type : None
Bad Blocks Exist: No
Is VD Cached: Yes
Cache Cade Type : Read Only
Exit Code: 0x00
我正在使用的命令是:
C:\Users\Administrator\Downloads\8-04-07_MegaCLI\Win_CliKL_8.04.07\MegaCliKL -LDInfo -Lall -aAll
如何使这些信息更具可读性?
我实际上只需要:名称,团队级别,大小,驱动器数量,状态和跨度深度。
它必须在powershell中才可行。
在此先感谢您的帮助!
扎克
解决方法
如果“更具可读性” 表示“仅将输出减少到以列出的项目开头的行” :
$MegaCliKL = & C:\Users\Administrator\Downloads\8-04-07_MegaCLI\Win_CliKL_8.04.07\MegaCliKL -LDInfo -Lall -aAll
$listedItems = '^\s*Name','Raid Level','Size','Number of drives','State','Span Depth' -join '|^\s*'
$MegaCliKL -match $listedItems |
ForEach-Object {
if ( $_ -match '^\s*Name' ) {''} # line separator
$_
}
输出:
Name :OS
RAID Level : Primary-1,Secondary-0,RAID Level Qualifier-0
Size : 558.375 GB
State : Optimal
Number Of Drives : 2
Span Depth : 1
Name :Storage
RAID Level : Primary-0,RAID Level Qualifier-0
Size : 7.275 TB
State : Optimal
Number Of Drives : 4
Span Depth : 1