I am trying to club multiple tab delimited files from a folder & get a unique result of distinct columns.
I have been able to make it work by passing the list of columns for the unique rows directly to Select-Object command.
However, I want to parameterise the unique columns list & pass it as a command argument because I am trying to create a function for this & expect the consumer to pass these values.
I have tried the below but it is not working & does not return any values.
$FileDate="20200420"
$TempFilePath="C:\Abdul\Work\Work From Home\TempFiles"
$DistinctColumnList="'ColA','ColB','ColC'"
$FilePattern = $FileDate + "*.SDE"
$FinalFileNamePath = "C:\Abdul\Work\Work From Home\TempOut" + "\" + $FileDate + "_Combined.csv"
$data = Import-Csv -Delimiter "`t" -Path (Get-ChildItem -Path $TempFilePath -Filter $FilePattern).FullName
#This Works!!
#$dataUnique =$data | Select-Object 'ColA','ColB','ColC' -Unique
#How do I make this work?
$dataUnique =$data | Select-Object $DistinctColumnList -Unique
$dataUnique | export-csv $FinalFileNamePath -notypeinformation
$Waits = Read-Host -Prompt 'Finished'
$DistinctColumnList="'ColA','ColB','ColC'"-->$DistinctColumnList = 'ColA','ColB','ColC'and$dataUnique =$dataUnique | Select-Object ...-->$dataUnique = $data | Select-Object ...