none
Creating a lot of VMs - Shared/Community Script RRS feed

  • General discussion


  • I saw an intersting script in the following link: PowerShell Script to Create Lots of Windows Server 2012 Hyper-V Virtual Machines at Once - http://www.aidanfinn.com/2012/03/powershell-script-to-create-lots-of-windows-server-8-hyper-v-virtual-machines-at-once/ (by the way, cool script)

    So, my need was a little different, so i´v customized a little bit, and there is!



    ## Based on "PowerShell Script to Create Lots of Windows Server 2012 Hyper-V Virtual Machines at Once"
    $parentpath = "C:\ClusterStorage\Volume1"
    $baseVHDX = "\BASE.VHDX"
    $vSwitchName = "EXTERNAL"
    $VMName = "VM_"


    foreach ($i in 1..200)
       {
    $VHDXfilename = "$parentpath\$VMName$i.VHDX"
        New-VHD -ParentPath "$parentpath$baseVHDX" -Differencing -Path "$VHDXfilename"
        New-VM -VHDPath "$VHDXfilename" -Name "$VMName$i" -Path "$parentpath" -SwitchName "$vSwitchName"
        ## Start-VM "$VMName$i"
    }


    After some time, my M630 and its 256 GB of RAM was fully loaded with 200 sysprep´d VMs

    Thursday, July 30, 2015 7:21 PM