I'm trying to fetch the perfmon counters and exporting the data to csv file.
$pg_co = "\Processor(_total)\% processor time"
$pg_Da = Get-Counter $pg_co
$pg_Da.counterSamples | Select-Object TimeStamp, CookedValue, RawValue | Export-CSV "D:\Qemu\test1.csv" -Append -NoTypeInformation
$pg_co = "\Memory\Available MBytes"
$pg_Da = Get-Counter $pg_co
$pg_Da.counterSamples | Select-Object TimeStamp, CookedValue, RawValue | Export-CSV "D:\Qemu\test1.csv" -Append -NoTypeInformation
But I'm unable to put these values in individual columns. The data gets overwritten(or in subsequent rows if I include -Append). When I query the counter for the second time, how can I put it in a new column? For example, I would want the csv to look like this, maybe with a different column name as CookedValue2 or anything. The expect outlook of csv file Any help would be greatly appreciated