Quantcast
Channel: VMware Communities : All Content - All Communities
Viewing all articles
Browse latest Browse all 175326

Unable to validate and add new harddisk

$
0
0

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


Viewing all articles
Browse latest Browse all 175326

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>