Created
January 4, 2018 01:00
-
-
Save technion/f3d673eae55b22b938222aa3cf7933a1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$VMs = import-csv -path '.\build list.csv' | |
$VMLOC = "C:\ClusterStorage\GoldTier03\iuhuih\" | |
$ISO = "C:\ClusterStorage\SilverTier1\ISO\SW_DVD9_Win_Svr_STD_Core_and_DataCtr_Core_2016_64Bit_English_-3_MLF_X21-30350.ISO" | |
foreach ($vm in $VMs) { | |
write-host "Creating VM " $vm.Name "With C: " $vm.C "and ram" $vm.RAM | |
$disksize = [int]$($vm.C) * 1024*1024*1024 #Convert byte string to GB | |
New-VM -Name $vm.Name -Path ${VMLOC} -MemoryStartupBytes 2GB -NewVHDSizeBytes $disksize -SwitchName vSwitch1 -Generation 2 -NewVHDPath "$($VMLOC)$($vm.Name)\disk-1.vhdx" | |
Get-VM -VM $vm.Name | Set-VMNetworkAdapterVlan -Access -Vlanid 1205 | |
$ramsize = [int]$($vm.RAM) * 1024*1024*1014 #Convert byte string to GB | |
Get-VM -VM $vm.Name | Set-VM -DynamicMemory -MemoryMaximumBytes $ramsize | |
#Add and mount DVD | |
Add-VMDvdDrive -VMName $($vm.Name) | |
$vmDVD = Get-VMDvdDrive -VMName $($vm.Name) | |
Set-VMFirmware -VMName $($vm.Name) -FirstBootDevice $vmDVD | |
Set-VMDvdDrive -VMName $($vm.Name) -Path $ISO | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment