I am trying to display unique values from each column in an array that is generated from a CSV file.
CSV file contains:
ENV,RELEASE,SERVERNAME
DEVL,2008,winhost01
DEVL,2008,winhost02
DEVL,2014,winhost03
DEVL,2016,winhost04
TEST,2008,winhost05
TEST,2014,winhost06
PROD,2008,winhost07
PROD,2014,winhost08
PROD,2014,winhost09
PROD,2014,winhost10
Expected output:
ENV
---
DEVL
TEST
PROD
RELEASE
---
2008
2014
2016
SERVERNAME
---
winhost01
winhost02
..etc..
winhost10
I go through each property in the array printing off the values. I get the first column's values in the first loop, but every column after that just prints an empty line (16 empty lines to be exact).
$arrayin = Import-Csv "Documents\Powershell\test.csv";
$cols = $arrayin[0].psobject.properties.name;
$i = 0;
do {
$arrayin | Select-Object -Property $cols[$i] -Unique;
$i++;
} until ($i -eq $cols.count)
Actual output:
ENV
---
DEVL
TEST
PROD
...16 empty lines follow...
How can I display the other array properties (columns?) instead of empty lines?