i have a csv sheet like one given below, (some cells can be empty, actual sheet i have is having upto disk 20),
ID name disk1 disk2 disk3
001 abc 50 50 50
002 def 100 100
003 xyz 50
I need to input this sheet to powershell script and add all three "disk" fields alone for each record and print it out, something like given below, only sum is sufficient not required ID or name fields, preferably i need a function to call for each record to return back the sum
150
200
50
tried this so far but no luck
$coll = import-csv "C:\input.csv"
foreach ($record in $coll)
{
for ($i=1; $i -lt 4; $i++)
{
[int]$totaldisk = @()
$diskname = "disk"+$i
$totaldisk += $record.$diskname
}
$totaldisk
}