This is an extremely quick post to help you create Hyper-V virtual machines using PowerShell. The script assumes you’ve already installed the Hyper-V feature in Windows.
You can define a bunch of variables *highlighted in red below* such as type of Checkpoint, or Memory or CPU settings, to define how your Virtual Machines are created.
The script prompts you for three inputs:
- Virtual Machine name
- Virtual Switch Name
- Generation type (Gen1=legacy, Gen 2=UEFI)
Here’s a screenshot of the script in action:
And after running you can see the Virtual Machine properties match what you specified (Gen 2, switch name, cpu settings and so on…)
and the New Virtual Switch is created (if it didn’t already exist)
Here’s the script ! Download it, unzip and Start PowerShell (or ISE) as Administrator to run.