I am using PowerShell to remotely configure storage arrays from various vendors. The script allows me to connect to the arrays with no issue. From there I run commands using REST API calls or remote SSH via plink.exe. Here is my issue. When using plink, I need to query the array and then perform operations conditionally based on the output. The issue is that the output is returned in string format. This is causing a problem for me because I would like to sort and extract portions of the returned string and present users with options based on the output.
Example - List Volumes
if ($sel_vendor -eq 3){
$ibm_ex_vols = & $rem_ssh $rem_ssh_arg1 $rem_ssh_arg2 $array_user"@"$array_mgmt_ip "-pw" $readpass "lsvdisk"
foreach ($i in $ibm_ex_vols){
write-host $i
}
}
Here is the output of the code
id name IO_group_id IO_group_name status mdisk_grp_id mdisk_grp_name capacity type FC_id FC_name RC_id RC_name vdisk_UID fc_map_count copy_count fast_write_state se_copy_count RC_change compressed_copy_count parent_mdisk_grp_id parent_mdisk_grp_name
0 Test1 0 io_grp0 online 0 SVC_SYSTEM_POOL 10.00GB striped 600507680C80004E980000000000074B 0 1 empty 1 no 0 0 SVC_SYSTEM_POOL
1 Test2 0 io_grp0 online 0 SVC_SYSTEM_POOL 10.00GB striped 600507680C80004E980000000000074C 0 1 empty 1 no 0 0 SVC_SYSTEM_POOL
2 Test3 0 io_grp0 online 0 SVC_SYSTEM_POOL 10.00GB striped 600507680C80004E980000000000074D 0 1 empty 1 no 0 0 SVC_SYSTEM_POOL
3 Test4 0 io_grp0 online 0 SVC_SYSTEM_POOL 10.00GB striped 600507680C80004E980000000000074E 0 1 empty 1 no 0 0 SVC_SYSTEM_POOL
What I would like to be able to do is store this info and then select the headers and data from the id and name columns. I was able to output the data to a txt file using the out-file command. Once I did that I used Excel to convert it to a delimited file using the fixed with delimiter option. While this worked, I need to figure out a dynamic solution.