$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"
the result is
Creation Time Employee ID
2014/10/14 1530 1
2014/10/14 1530 2
2014/10/14 1532 1
2014/10/14 1532 2
how can add the header...for examples
report<--title
Creation Time Employee ID
2014/10/14 1530 1
2014/10/14 1530 2
2014/10/14 1532 1
2014/10/14 1532 2