Picture this scenario – you are at the pointy end of a major modern management project and it’s time to test every policy, configuration and application at scale and quickly.
What do you do? With infinite money, infinite time and a willing client, you take over their VC meeting room and stack dozens of devices on a desk and blast slayer while you verify your builds ( this literally has happened to me)..
But what if you don’t have infinite money, time or an understanding client? That’s where Hyper-V and my latest module Intune.HV.Tools come in handy!
Enough intro – let’s dive right in.
Open your favourite terminal as admin – PowerShell 5.1 or 7 will work. Haven’t installed 7 yet? give it a go, it’s easy to install and awesome.
Let’s begin by installing the module..
Once the module is installed, we need to set up our device using the functions contained within..
Let’s start by initializing everything..
All we are doing here is specifying where we want our VMs to be stored and preparing the configuration file – which we can look at by running the “Get-HVToolsConfig” command..
Now that we have our configuration file initialized, let’s add stuff to it!
The first thing we need to add is details of our windows installation media – in the example below we are using the latest “2004” build of windows 10..
We can add as many images to the solution as we want – all we need to do is make sure each one has a unique name – as shown below, I’ve added builds 1909 and 2004 to my lab..
Once we have our image library added to the config, let’s add some of our tenants (one at a time of course..)
What’s cool about the Add-TenantToConfig cmdlet is that the ImageName parameter autocompletes from the available images that we added in the step before. Only have one image? press Tab and it’ll autocomplete. You added a few images? Tab through and find the one you want to use!
Alright, we’ve got our images and our tenants configured, lastly we need to add our Hyper-V VLAN details – most of us probably just have the “Default Switch” that was set up when we install Hyper-V, but *some* of us have complex setups, so let’s solve that.
The cmdlet actually auto-completes against any virtual switches you might have set up, so as always, just tab through and find the switch you want to assign to your machines..
If you have a virtual network that requires a VLanID you can also apply that by using the -VlandID parameter..
Alright, once our configuration is set up, it’s time to build our VMs. For this example I’m going to build 3 VMs with a single CPU and 2gb of memory to enroll to the “Powers-Hell” tenant..
The first time you build a VM from an image it needs to create a reference image which can take some time – this will only need to be done once per image.
We will also check for any available Autopilot configuration profiles. If we want to skip that and just spin up test machines we can use the -SkipAutoPilot switch..
Once we’ve captured the Autopilot configuration profile we will use the local copy moving forward..
Let’s watch what happens once we already have the reference image created..
Awesome – we now have 3 machines we can use to verify our Autopilot configuration, all other Intune policies, configurations and applications work.
The usual caveat emptor rules apply – this works for me – I’ve tested it pretty heavily, but it may not work for you.
If it doesn’t work for you, please raise an issue on the GitHub and I’ll try fix it for you.
There are plenty of things I plan to add to this – so please check back regularly!