function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.SubArgs+=$_.Index-1-$Header.SubArgs[0] $Header } $Header=[PSCustomObject]@{ Name=$_.Value SubArgs=,$_.Index } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object[$_$Object.Name]=$StringAdd($_.Name,$String.Substring.Invoke($_.SubArgs).TrimEnd()) } { [PSCustomObject]$Object } } } } function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.SubArgs+=$_.Index-1-$Header.SubArgs[0] $Header } $Header=[PSCustomObject]@{ Name=$_.Value SubArgs=,$_.Index } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object[$_.Name]=$String.Substring.Invoke($_.SubArgs).TrimEnd() } { [PSCustomObject]$Object } } } } function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.SubArgs+=$_.Index-1-$Header.SubArgs[0] $Header } $Header=[PSCustomObject]@{ Name=$_.Value SubArgs=,$_.Index } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object.Add($_.Name,$String.Substring.Invoke($_.SubArgs).TrimEnd()) } { [PSCustomObject]$Object } } } } @'$ibm_ex_vols=@' 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 '@-split'\r?\n'|Parse\n' $ibm_ex_vols|Parse-Data @' 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 '@-split'\r?\n'|Parse-Data $ibm_ex_vols=@' 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 '@-split'\r?\n' $ibm_ex_vols|Parse-Data function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.Width=$_SubArgs+=$_.Index-1-$Header.Position-1SubArgs[0] $Header } $Header=[PSCustomObject]@{ Name=$_.Value Position=$_SubArgs=,$_.Index Width=0 } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object[$_.Name]=$String.Substring.Invoke(@( $_.Position if($_.Width){ $_.Width } )SubArgs).TrimEnd() } { [PSCustomObject]$Object } } } } function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.Width=$_.Index-$Header.Position-1 $Header } $Header=[PSCustomObject]@{ Name=$_.Value Position=$_.Index Width=0 } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object[$_.Name]=$String.Substring.Invoke(@( $_.Position if($_.Width){ $_.Width } )).TrimEnd() } { [PSCustomObject]$Object } } } } function Parse-Data{ begin{ $Headers=$null } process{ if(!$Headers){ $Headers= [Regex]::Matches($_,'\S+')| ForEach-Object { $Header=$null } { if($Header){ $Header.SubArgs+=$_.Index-1-$Header.SubArgs[0] $Header } $Header=[PSCustomObject]@{ Name=$_.Value SubArgs=,$_.Index } } { $Header } }else{ $String=$_ $Headers| ForEach-Object { $Object=[ordered]@{} } { $Object[$_.Name]=$String.Substring.Invoke($_.SubArgs).TrimEnd() } { [PSCustomObject]$Object } } } } Loading
lang-bash