【发布时间】:2014-10-13 09:03:42
【问题描述】:
#Create an empty System.Array object
$employees = @()
#Add newly created object to the array
#$employees += $employee
for ($i=1;$i -le 2;$i++)
{
$employee = New-Object System.Object
$employee | Add-Member -MemberType NoteProperty -Name "Creation Time" -Value $(Get-date)
$employee | Add-Member -MemberType NoteProperty -Name "Employee ID" -Value $($i.ToString("D2"))
$employees += $employee
Start-Sleep -Seconds 1
}
#Finally, use Export-Csv to export the data to a csv file
$employees | Export-Csv -NoTypeInformation -Path "c:\temp\test\EmployeeList.csv"
这是代码写入数据覆盖旧数据,我想同样更改代码,添加“-Append”
$employees | Export-Csv -NoTypeInformation -Path "c:\temp\test\EmployeeList.csv" -Append
错误信息:
Export-Csv:找不到与参数名称“附加”匹配的参数。 在 D:\powershell\MU_TAG_ET.ps1:292 char:70 + $员工 | Export-Csv -Path "c:\temp\test\EmployeeList.csv" -Append + CategoryInfo : InvalidArgument: (:) [Export-Csv], ParameterBindingException + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ExportCsvCommand
你能帮帮我吗??
【问题讨论】:
-
-append从 3.0 版本开始。你在 powershell 2.0 中吗?
标签: powershell csv