Another option is to create a custom PSObject:
$data = @() $data += New-Object –TypeName PSObject -Property ` (@{'ComputerName'="server10"; 'Name'= @("Spooler", "Server", "Workstation");}) $data += New-Object –TypeName PSObject -Property ` (@{'ComputerName'="exch10"; 'Name'= @("BITS", "NtFrs", "MSMQ", "Kdc");}) $data | Get-Service | Select MachineName, Name, DisplayName, Status
Additionally, if you would like to keep the data source in another file you can export the above to an XML file (CSV will not hold the object [array] type):
$data | Export-CliXML C:\Temp\test.xml
and then you can do something like this:
$xmlData = Import-Clixml C:\Temp\test.xml $xmlData | Get-Service | Select MachineName, Name, DisplayName, Status