If you for example import a .csv file and loop trough it with with PowerShell, each entry is from the type PSCustomObject.

Recently I wanted to see an easy way to get the column names from the .csv file as well as the values, so I found out this very easy solution:

$csv | ForEach-Object {
 $row = $_;
 #give an array of columns for this item
 $columns = ($row.PSObject.Properties.Name);
 #gives an array of the values for this item
 $data = $row.psobject.Properties.Value;

I also wanted to do a comma separated list of the values, which I did with the following snippet:

 $commas_columns = $columns -join ",";
 $commas_data = "'{0}'" -f ($data -join "','");