by willbs at 2013-02-22 13:49:09
i am running powershell 3by mjolinor at 2013-02-22 21:48:26
i am running a test and the results go to a csv file
the output of my first test has 3 columns
nTest NumbertTest Title `tTest Results" | out-file -filepath C:\TestReport.csv -append
then i fill in the columns with the test results
then i run the second test, the output of the second test is this code whis has 2 columns
Get-Process | Select-Object name, fileversion | export-csv -path C:\TestReport.csv -notype -append -force
i get this error
export-csv : Cannot process argument because the value of argument “name” is not valid. Change the value of the “name” argument and run the operation again.
At C:\Users\xxxxx\Documents\PowerShell\PS_Check_Process_Version.ps1:4 char:49
+ Get-Process | Select-Object name, fileversion | export-csv -path C:\TestReport.c …
+ CategoryInfo : InvalidArgument: ( [Export-Csv], PSArgumentException
+ FullyQualifiedErrorId : Argument,Microsoft.PowerShell.Commands.ExportCsvCommand
if i switch the test order then the 3 columns are placed in the first column
which ever test is run first always appears correctly, it’s the second test that looks like crap or i get an error
is there a way to clear or reset things so i can append mixed outputs to the same csv file?
thanks in advance
Powershell won’t let you do that, for good reason. Having rows with different numbers of fields and disparate data in the same file essentially renders it “broken” as a .csv file.