I have a csv file with only one column like below
Column1
Apple
Mango
I am try to append the csv to add more fruits by appending the current csv file with the following script
$path = Split-Path -parent $MyInvocation.MyCommand.Definition
$csvPathforFruits = $path + "\Fruits.csv"
$importFruit = Import-Csv $csvPathforFruits
$new = "Orange"
$new | Export-CSV $csvPathforFruits -Append
But following error is thrown out.
Export-CSV : Cannot append CSV content to the following file: C:\Users\sysadmin\Desktop\Test\Fruits.csv. The appended object does not have a property that corresponds to the following column:
Colume1. To continue with mismatched properties, add the -Force parameter, and then retry the command.
At C:\Users\sysadmin\Desktop\Test\tt.ps1:5 char:9
+ $new | Export-CSV $csvPathforFruits -Append
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (Colume1:String) [Export-Csv], InvalidOperationException
+ FullyQualifiedErrorId : CannotAppendCsvWithMismatchedPropertyNames,Microsoft.PowerShell.Commands.ExportCsvCommand
Can anyone point out my mistakes.