首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Powershell + MegaCLI -使输出更具可读性

Powershell + MegaCLI -使输出更具可读性
EN

Stack Overflow用户
提问于 2020-10-30 22:39:07
回答 1查看 67关注 0票数 0

寻求一些帮助,使MegaCli命令的输出更具可读性。

输出为:

代码语言:javascript
复制
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, ReadAdaptive, Direct, 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, Secondary-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, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteBack, ReadAdaptive, Direct, 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

我使用的命令是:

代码语言:javascript
复制
C:\Users\Administrator\Downloads\8-04-07_MegaCLI\Win_CliKL_8.04.07\MegaCliKL -LDInfo -Lall -aAll

我怎样才能使这些信息更具可读性呢?

我实际上只需要:名称、Raid级别、大小、驱动器数量、状态和跨度深度。

它必须在powershell中是可行的。

提前感谢您的帮助!

扎克

EN

回答 1

Stack Overflow用户

发布于 2020-10-31 05:18:08

如果“更具可读性”意味着“仅将输出减少到以所列项目开头的行”

代码语言:javascript
复制
$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
        $_
    }

输出

代码语言:javascript
复制
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, Secondary-0, RAID Level Qualifier-0
Size                : 7.275 TB
State               : Optimal
Number Of Drives    : 4
Span Depth          : 1
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64610471

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档