How to handle array with split and substring and foreach to output below information.
I have tried with split and substring. But still not work. Thanks.
$item=$item.ToString()
$driveID=$item.Substring(0,26)
$ID=($driveID.Split(":")[-1]).trim()
$status=$item.Substring(27,$item.Length-1-27)
$stauts1=($status.split(",")[-1]).trim()
input【array】:
physicaldrive 1I:1:9 (port 1I:box 1:bay 9, SAS HDD, 900 GB, OK)
physicaldrive 1I:1:10 (port 1I:box 1:bay 10, SAS HDD, 900 GB, OK)
physicaldrive 1I:1:11 (port 1I:box 1:bay 11, SAS HDD, 2.4 TB, OK, spare)
physicaldrive 1I:1:12 (port 1I:box 1:bay 12, SAS HDD, 900 GB, OK, shared spare)
Expected output:
DriveID DriveStatus
9 OK
10 OK
11 OK
12 OK