I have CSV file

My PowerShell Script attempts to store SourceIP, DestinationIP, and Traffic in multidimensional array
$source = @((Import-Csv D:\Script\my.csv).SourceIP)
$dest = @((Import-Csv D:\Script\my.csv).DestinationIP)
$t = @((Import-Csv D:\Script\my.csv).Traffic)
$multi = @($source),@($dest),@($t)
When I try to read from first element of $multi, I expect to get a list of SourceIP
foreach ($q in $multi){
write-host $q[0]
write-host `n
}
But instead, I get SourceIP, DestinationIP, Traffic, i.e.
10.153.128.110
10.251.68.80
3.66 GB
And if I try
foreach ($q in $multi){
write-host $q[0][0][0]
write-host `n
}
I get
1
1
3
How to troubleshoot?
UPDATE
Ultimate goal is to
- Count total traffic
- Count traffic if SourceIP or Destination IP fits into certain pattern, i.e. 10.251.22.x
- Get percentage
UPDATE II
I am able to get code to import CSV and tally total bandwidth only, but I also need bandwidth from SourceIP and DestinationIP with certain pattern.
$t = @((Import-Csv D:\Script\my.csv).Traffic)
foreach ($k in $t){
write-host $k
}
foreach ($i in $t){
$j += ,@($i.split(" "))
}
foreach ($m in $j){
switch ($m[1]){
GB {
$m[0] = [int]($m[0]) * 1000
$m[1] = 'MB'
}
MB {}
KB {
$m[0] = [int]($m[0]) / 1000
$m[1] = 'MB'
}
}
$total_bandwidth += $m[0]
}
write-host Total bandwidth is ("{0:N2}" -f $total_bandwidth) MB
multi[0]?[string]to[ipaddress]and compare it$ip.sortableaddressfrom the limits you want and go on...