#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"
this is code write data is overwrite old data,i want to same change code, add "-Append"
$employees | Export-Csv -NoTypeInformation -Path "c:\temp\test\EmployeeList.csv" -Append
error message:
Export-Csv : A parameter cannot be found that matches parameter name 'Append'.
At D:\powershell\MU_TAG_ET.ps1:292 char:70
+ $employees | Export-Csv -Path "c:\temp\test\EmployeeList.csv" -Append <<<<
+ CategoryInfo : InvalidArgument: (:) [Export-Csv], ParameterBindingException
+ FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.Commands.ExportCsvCommand
can u help me??
-append
is starting from 3.0 version. Are you in powershell 2.0? – CB.