我有一个文件如下。我希望它将其转换为 CSV,并希望仅对项目驱动器、驱动器类型、总空间、当前分配和剩余空间拥有它的网格视图。
PS C:\> echo $fileSys
Storage system address: 127.0.0.1
Storage system port: 443
HTTPS connection
1: Name = Extreme Performance
Drives = 46 x 3.8T SAS Flash 4
Drive type = SAS Flash
RAID level = 5
Stripe length = 13
Total space = 149464056594432 (135.9T)
Current allocation = 108824270733312 (98.9T)
Remaining space = 40639785861120 (36.9T)
我是 Powershell 的新手,但我已经尝试了以下两件事的代码,但它甚至没有得到我想要的输出。
$filesys | ForEach-Object {
if ($_ -match '^.+?(?<Total space>[0-9A-F]{4}\.[0-9A-F]{4}\.[0-9A-F]{4}).+?(?<Current allocation>\d+)$') {
[PsCustomObject]@{
'Total space' = $matches['Total space']
'Current allocation' = $matches['Current allocation']
}
}
}