$host1 = "<HostIP>"
Connect-VIServer -Server $host1 -User user -Password pass
$vmname = Get-VM
$n = $vm = 0
$datastore = Get-Datastore DS*
for($i = 0; $i -le $num_disks; $i++) {
$size = $datastore[$i].CapacityGB - 1 #Deducting 1GB from each Datastore. Full sized DS as a VM fails as it need some space to write VM data
$vmnamenew = $vmname[$i]
write-host "Size of VMDK to be added : ", $size
write-host "VMname will be : ", $vmnamenew
write-host "Datastore used is : ", $datastore[$n]
New-HardDisk -vm $vmnamenew -CapacityGB ($size) -Datastore $datastore[$n] -StorageFormat $format #Mounting the Datastore to VMs.
Start-Sleep -s 20
代码段类似于:
相关问题 更多 >
编程相关推荐