Hi.
I’m trying to extract substrings and values from a table. I need to extract the Size, Used and Avail figures so that I end up with the following:
Raw: 292.2
Size: 286.4
Used: 66.8
PctUsed: 23
Avail: 219.6
PctAvail 77
I’ve gotten this far:
$tbl = "Cluster Name: Isilon01",
"Cluster Health: [ ATTN]",
"Cluster Storage: HDD SSD Storage",
"Size: 286.4T (292.2T Raw) 0 (0 Raw)",
"VHS Size: 5.8T",
"Used: 66.8T (23%) 0 (n/a)",
"Avail: 219.6T (77%) 0 (n/a)"
$OutTbl = @()
ForEach($t in $tbl) {
If($t -match "Size") {
$OutObj = "" | Select Size, Used, Avail
$OutObj.Size = $t.Split(":",2)[1].Trim()
}
ElseIf($t -match "Used") {
$OutObj.Used = $t.Split(":",2)[1].Trim()
}
ElseIf($t -match "Avail") {
$OutObj.Avail = $t.Split(":",2)[1].Trim()
$OutTbl += $OutObj
}
}
$OutTbl | FL
This generates the following:
Size : 5.8T
Used : 66.8T (23%) 0 (n/a)
Avail : 219.6T (77%) 0 (n/a)
Now I need to process further to take out the “T’s” and get split on the percentages. I thought of using the substring but the length of the values vary.
Any help or suggestions much appreciated.