BenH's helpful answer works well with your particular input and he makes a good point in general: when you call external utilities (command-line applications), all you get back are lines of text, unlike with PowerShell-native commands that pass objects around.
Parsing strings (text) will always be more brittle than dealing with objects (which is why PowerShell's fundamental object orientation represents a great evolutionary leap in shell design).
That said, if you can make certain assumptions about the formatting of the strings you receive, PowerShell offers great tools to help even with that:
Imagine a function Select-Column that selects whitespace-separated fields (column values) by index from each input line (vaguely akin to awk):
@'
List of Runbook ID on the system:
List of services installed on the system:
ALMService Version: 7.0.4542.16189
AOSService Version: 7.0.4542.16189
BIService Version: 7.0.4542.16189
DevToolsService Version: 7.0.4542.16189
DIXFService Version: 7.0.4542.16189
MROneBox Version: 7.1.1541.3036
PayrollTaxModule Version: 7.1.1541.3036
PerfSDK Version: 7.0.4542.16189
ReportingService Version: 7.0.4542.16189
RetailCloudPos Version: 7.1.1541.3036
RetailHQConfiguration Version: 7.1.1541.3036
RetailSDK Version: 7.1.1541.3036
RetailSelfService Version: 7.1.1541.3036
RetailServer Version: 7.1.1541.3036
RetailStorefront Version: 7.1.1541.3036
SCMSelfService Version: 7.1.1541.3036
'@ -split '\r?\n' |
Select-Column -Index 0 -RequiredCount 3
The above, due to selecting the 1st column (-Index 0 - multiple indices supported) from only those lines that have exactly 3 fields (-RequiredCount 3), would yield:
ALMService
AOSService
BIService
DevToolsService
DIXFService
MROneBox
PayrollTaxModule
PerfSDK
ReportingService
RetailCloudPos
RetailHQConfiguration
RetailSDK
RetailSelfService
RetailServer
RetailStorefront
SCMSelfService
Select-Column source code:
Note that if you specify multiple (0-based) column indices, the output fields are tab-separated by default, which you can change with the -OutFieldSeparator parameter.
Function Select-Column {
[cmdletbinding(PositionalBinding=$False)]
param(
[Parameter(ValueFromPipeline, Mandatory)]
$InputObject,
[Parameter(Mandatory, Position=0)]
[int[]] $Index,
[Parameter(Position=1)]
[int] $RequiredCount,
[Parameter(Position=2)]
[string] $OutFieldSeparator = "`t"
)
process {
if (($fields = -split $InputObject) -and ($RequiredCount -eq 0 -or $RequiredCount -eq $fields.Count)) {
$fields[$Index] -join $OutFieldSeparator
}
}
}