What I've noticed is that when the code is in the main body, this line:
$fCustomerVPGs | % {
...cycles thru all the values one by one so the variable "$_.ProvisionedStorageInMB" only has one value at a time. However, since moving the code to a function, the variable now has multiple values.
For example, I modified the code to this:
$fProvisionedStorageInMB = $_.ProvisionedStorageInMB
Write-Host "ProvisionedStorageInMB: $fProvisionedStorageInMB"
$fProvisionedStorageInGB = $fProvisionedStorageInMB /1kb
And the Write-Host shows the following when I step the code:
ProvisionedStorageInMB: 1438851 533470 5576093 41549798 42807 244205 1776643 512017 7202102 492230 803842 2429852 822601 875526 4313810 2528873 1136643 256005 250882 534474 585804 5593917 153931 841686 1153669 493042 368641 1331202 5989379 3098225 3123205 3 68816 163846 665604 601433 184323 81921 1127350 409612 1991941 665604 419871 22478034 360320 615944 2528873 164439 1402881 81928 9125613 102411 153931 1274028 972443 3123205 547891 739349 144288 245766 184322 1535946 553291 2429852 368816 384004 144310 5989 379 266251 4313810 13615268 81933 368641 5570570 368823 220216 44688 410849 20481 4834306 1622284 655428 22737 430084 584328 5593917 124405 1331202 11545627 579888 1136643 410388 81923 81921 7419907 1440783 411650 12509 737402 565670 409610 163846 164329 94 412 1776643 525190 1422366 188420 133152 41142 379083 2705571 409612 601433 3098225 512017 865282 82036 123078 225284 250882 532572 43334 1482115 512020 3445735 1438851 370100 1353157 824323 822601 841686 81946 410343 215243 5576093 1127350 1991941 2048008 803842 60457 124011 487762 7202102 256005 405906 256002 875526 585804 455684 1372369 840477 470521 165052 81923
It should only have ONE value!?