The following script will move all of the VMs on a Hyper-V host to a new storage location. In this case we are moving the VMs from “C:\VM\VirtualMachines\” to “D:\VM\VirtualMachines\.” This script assumes that the VM disks are kept in the VM folder and not in a separate location.
foreach ($VM in $VMs)
Move-VMStorage -VM $(Get-VM $VM.Name) -DestinationStoragePath $Path
I’ve created the exact same lab a dozen times with the same three Linux hosts. It’s time to automate the process with a script. The scripts assume that the virtual switches are already created, although their creation or a check to verify their existence could easily be added.
The first host, RT-ISP-01, is a router that has one interface on the connected to the “External” switch for access to the Internet and an interface on the “Network A” and “Network B” private switches. The other two hosts, SVR-A-01 and SVR-B-01, are attached to the “Network A” and “Network B” respectively.
Each host gets 512MB of RAM and a single 40GB hard drive.
The initial setup of these Linux hosts require that legacy interfaces are used at first. The script removes the default interface and adds the appropriate legacy interfaces.
Each host has its DVD drive configured to contain the Linux install ISO so that it is ready to go when the host is started. Continue reading “PowerShell to Create Multiple Hyper-V VMs”