I am trying to get PowerShell to give me the count of rows in a csv file and if there are 1 rows or more(aside from the header), email the files. Every csv file has a header and some have a trailing comma which is causing problems.
So in PowerShell 1.0 you cannot use the -Header() or you get this error:
Import-Csv : A parameter cannot be found that matches parameter name 'Header'.
That pops up when I try to:
Import-Csv \\somedirectory\my.csv -Header (gc \\somedirectory\my.csv).trim(",").split(",") | select -skip 1
$size1 = 0
#$size1 = $size1 + (Import-Csv \\somedirectory\my.csv).count
above fails due to the trailing comma with the famous:
Import-Csv : Cannot process argument because the value of argument "name" is invalid. Change the value of the "name" ar
gument and run the operation again.
Any help would be greatly! appreciated.