Looks like your delimiter is a blank line. How about reading the file and processing it so the first line is server name, all the following lines until a blank are an array of data, and then on blank lines it outputs a custom object with the server name and array of data as properties, and creating an array of those object?
Hm, that's confusing, and I wrote it. Let me post code, and then explain it.
$Server = ""
$Data = @()
$Collection = @()
Switch(GC C:\temp\test.txt){
{[String]::IsNullOrEmpty($Server) -and !([String]::IsNullOrWhiteSpace($_))}{$Server = $_;Continue}
{!([String]::IsNullOrEmpty($Server)) -and !([String]::IsNullOrEmpty($_))}{$Data+=$_;Continue}
{[String]::IsNullOrEmpty($_)}{$Collection+=[PSCustomObject]@{Server=$Server;Data=$Data};Remove-Variable Server; $Data=@()}
}
If(!([String]::IsNullOrEmpty($Server))){$Collection+=[PSCustomObject]@{Server=$Server;Data=$Data};Remove-Variable Server; $Data=@()}
Ok, it starts out by defining variables as either empty strings or arrays.
Then it processes each line, and performs one of three actions depending on the situation. The first line of the switch reads the text file, and processes it line by line. The first option in the Switch basically reads:
If there is nothing stored in the $Server variable, and the current line is not blank, then $Server = Current Line. Continue to the next line.
The second option is:
If $Server is not blank, and the current line is not blank, add this line to the array $Data. Continue to the next line.
The last option for the Switch is:
If the current line is blank, then this is the end of the current record. Create a custom object with two properties. The first property is named Server, and the value is whatever is in $Server. The second property is named Data, and the value is whatever is in $Data. Then remove the $server variable, and reset $Data to an empty array.
After the switch it checks to see if $Server still has data, and outputs one last object if it does. I do this in case there is no blank line at the end of the last record, just as cleanup.
What you are left with is $Collection being an array of objects that looks something like this:
Server Data
------ ----
[Server1] {Value_A , Value_B , Value_C}
[Server2] {Value_A}
[Server3] {Value_A , Value_B , Value_C , Value_D}