So I currently have a script that has the followning variables
$HDD1 = "20"
$HDD2 = "0"
here is a snipit of the code from my script. $HDD1 and $HDD2 are in addition to the vmdks based off the template I am using. There may be a time when I need one additional disk, another time I may need two additional disks.
If I do not need $HDD2, I would prefer to set it to zero as a way of defining it is not in use.
Right now if I run my script and put $HDD2 = 0 as above. The script completes sucessful and only adds $HDD1 as I would hope, but in powercli it does display errors pertaining to "invalid value passed for SizeGB" it does not like "0" for $HDD2
I am wondering if I should just add this to the the line below pertianing to $HDD2? -ErrorAction SilentlyContinue
Or is there a better way to deal with this?
thank you!!!
$vm | Set-VM -NumCpu ( $cpu ) -Confirm:$false
$vm | New-HardDisk -CapacityGB $HDD1
$vm | New-HardDisk -CapacityGB $HDD2
$vm | Set-VM -Notes $Note -Confirm:$false
Start-VM -VM $vmname