While working on a script to set the auto-grow max sizes on a given NetApp head (which I will post more about soon), I ran into the following problem.
The script uses Get-NAVol to find the existing volume total size. It then calculates a auto-grow max size by multiplying the existing volume total size by 1.2, to give an auto-grow size of 20% greater, and storing that number in a variable. It then uses Set-NAVolAutosize to set the new size.
This sounds like it should work, but instead Set-NAVolAutosize throws errors:
Set-NaVolAutosize : Invalid size: 386547056640.0
Where did that decimal come from? Let’s take a look. First, let’s examine the volume total size returned by Get-NaVol.
$Volumes = Get-NAVol
$Volumess.totalsize | gm
$Volumes.totalsize * 1.2 | gm
Well, that shows where our decimal is coming from! What happens if we set a variable to the number reported as the total volume size (354334801920)?
$number = 354334801920
$number | gm
Using set-navolautosize using the variable $number works. So, it would appear that the type System.Decimal is causing the problem. The solution? Explicitly cast the result of multiplying the total volume size by 1.2 as an Int64. The below assumes $volume is a variable holding a single object from Get-NAVol.
$NewAutoSize = [int64]($Volume.totalsize * 1.2)
This solved my problem.
In the next week or two I will publish the entire script to set new auto-grow sizes.