PS C:\Users\Rob> $obj
Name Group
---- -----
John GroupA
Jane GroupB
Mike GroupC
James GroupD
Based on what you posted, you want to convert object properties into arrays. Let’s look at how to convert a single object property into an array:
# Use Select-Object to Expand the property
$names = $obj | Select-Object -ExpandProperty Name
# Use an implicit for each loop
$names = $obj.Name
# Use an explicit for each loop
$names = $obj | foreach{$_.Name}
All of these convert the Name property\column into an array:
PS C:\Users\Rob> $names
John
Jane
Mike
James
If you wanted to do this for every property in the object, then you can do a loop for every property and create a new array variable. This would create new variables called $name and $group, but could difficult to find since we are generating them dynamically, so this will append a double underscore: