Am very new to powershell topic , I just want a help from you all . I need to merge multiple CSV file in a folder , in which this CSV files have same headers and different data , but in some cases two or more columns may have same data .
So here is my code ,
$filevalues = Import-Csv -Path (Get-ChildItem -Path C:\Users\hi\ -Filter '*.csv').FullName
$firstfile = Import-Csv -Path C:\Users\hi\VM1.csv
[String[]]$NamesofApplication = $firstfile.Application;
[String[]]$NamesofFolder = $firstfile.FileName;
[String[]]$NamesofConfigvariable = $firstfile.ConfigVariable;
[String[]]$NamesofVM1 = $filevalues.VM1;
[String[]]$NamesofVM2 = $filevalues.VM2;
[String[]]$NamesofVM3 = $filevalues.VM3;
Write-Host $NamesofVM1.Count
$array = @();
for($i=0; $i -lt $NamesofApplication.Count ; $i++){
$hashtable = [pscustomobject]@{Application=$NamesofApplication[$i]; FileName=$NamesofFolder[$i]; ConfigVariable=$NamesofConfigvariable[$i];VM1=$NamesofVM1[$i];VM2=$NamesofVM2[$i];VM3=$NamesofVM3[$i] };
$array += $hashtable;
};
$array | ForEach-Object { [pscustomobject] $_ } | Export-Csv C:\Users\hi\OutPut.csv
and here is my VM1.csv,VM2.csv and VM3.csv VM1.csv , VM2.csv , VM3.csv
and i just want my output to be like Output.csv
Can anyone help me in this .