How can I quickly create a Hyper-V Virtual Machine using PowerShell

Introduction

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)

Downloads

Here’s the script ! Download it, unzip and Start PowerShell (or ISE) as Administrator to run.

Create HyperV VM2

This entry was posted in hyper-v, PowerShell. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.