Hi,
I am unable to validate and add new harddisk from below script. I want to validate, if the value is greater than 0 then add the hardisk else skip this step.
$vmlist = Import-CSV ".\vmdeploy1.csv" -UseCulture
foreach ($item in $vmlist) {
#Grabbing the vm object once for efficiency.
$VM = Get-VM $item.vmname
#Add Harddisk
if($item.ahdd -gt 0){
$VM | New-HardDisk -CapacityGB $item.ahdd -Confirm:$false
}
else
{
Get-VM $vm | Start-VM -Confirm:$false
}
}
There is no error and harddisk.is not getting added.
Please help