0
我有只有一列像下面PowerShell的追加CSV错误
Column1
Apple
Mango
我尝试追加CSV用下面的脚本
$path = Split-Path -parent $MyInvocation.MyCommand.Definition
$csvPathforFruits = $path + "\Fruits.csv"
$importFruit = Import-Csv $csvPathforFruits
$new = "Orange"
$new | Export-CSV $csvPathforFruits -Append
附加当前的CSV文件中添加更多的水果csv文件
但是下面的错误被抛出。
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
任何人都可以指出我的错误。