Csv fie sorting and comparing with another

i have extracted memberof list for AD user an extracted into CSV file which contains 20 rows in single column without any name column , i am trying to sort using Import-Csv -Path “I:$SID.csv” | sort command
but its not working,

also if someone can help comparing 2 CSV file for 2 different AD user to check for common and uncommon memberof AD groups, tried import-CSV help but no luck

Try defining a header

Import-Csv -Path “I:$SID.csv” -Header Name  | Sort-Object -Property Name

If you import both CSVs, then you can use Compare-Object. If you cannot get it to work, provide examples of the data, expected outcomes, errors, etc.

this is working however it displays on PS ISE screen i tried | out-file “i: $SID.csv” but it shows blank file
this is the same file which i am sorting.

If you have structured data and you want to save them to a file instead of Out-File you should use

to export them to a proper CSV file. Please read the help completely including the examples to learn how to use it.

export csv will create new file but here same csv file which has all memberof list are unable to sort out

I don’t understand that. Could you elaborate a little more detailed please? You may share some sample data (formatted as code please).

Thanks in advance.

1 Like