Afaik, there is no direct metric that gives you those numbers over the last 7 days (Historical Interval 2).

Also remember that the metrics are aggregated for the Historical Intervals.

See my PowerCLI & vSphere statistics – Part 1 – The basics post for more details on this.

If you ask for metric values over the last 7 days, you could use the **net.bytesRx.average** and **net.bytesTx.average**.

This will give you the average number of bytes transmitted and received during the interval.

If you multiply the average number of bytes (KBps) by the number of seconds in the interval you should get a decent approximation of the absolute values you are after.

Something like this

Get-VM |
Get-Stat -Stat "net.bytesRx.average","net.bytesTx.average" -Start (Get-Date).AddDays(-7) |
Group-Object -Property {$_.Entity.Name} |
Select @{N="VM";E={$_.Name}},
@{N="Received (KB)";E={
($_.Group | where {$_.MetricId -eq "net.bytesRx.average"} | %{$_.Value * $_.IntervalSecs} |
Measure-Object -Sum).Sum}},
@{N="Transmitted (KB)";E={
($_.Group | where {$_.MetricId -eq "net.bytesTx.average"} | %{$_.Value * $_.IntervalSecs} |
Measure-Object -Sum).Sum}}

Note that this script will summarise traffic for all vNICs that a VM has.

The script also requires at least statistics level 2 for Historical Interval 2.