Script syntax is below: $VMName = Read-Host 'Name your VM' Connects the VM to the newly copied and renamed VHDX.Assigns the VM to have 4 GB of RAM and 2 vCPU.Copies your template disk file to c:\hyper-v\$vmname.You’ll need to change the name of the vswitch if your vswitch is not named external. The script can be edited to adjust hardware as needed. It will already contain the get-windowsautopilotinfo script, so you can get testing quickly without any additional steps. When it finishes, you can power up your VM and it will go through OOBE. The script is available on github and accomplishes the list of items below. Now that we have our disk image, we will use it as our template when creating our new test machines. I moved my vhdx to a directory c:\hyper-v\w10_image\ on my PC. Once the VHDX is copied, you can delete the VM and its files we used to build this. Navigate to the VHDX file and move/copy it into another directory. This is the only component we are interested in since it has our sysprepped windows 10 install. Once the VM completes sysprep and powers off, we want to copy the VHDX file. Wait for the sysprep to finish and the VM to be shutdown: Make sure you check the box to generalize and make the shutdown option to shutdown the PC. To sysprep the machine, open a command prompt and navigate to c:\windows\system32\sysprep and launch sysprep.exe. I also install the script get-windowsautopilotinfo since I test autopilot often (this installs the script on the disk image and saves you from having to install the script every time you make a new test machine). Before sysprep, remove any mounted ISO files you used for the OS install. Once your OS is updated, we need to sysprep the image. I use Windows 10 Pro for most of my work, so that’s the version I chose. Install your desired version of Windows and update your OS. I also recommend to disable checkpoints/snapshots before starting the VM for the first time. The specs on this machine don’t really matter since we will be deleting it after we get our disk image, but I set the hardware the same I use for my test machines anyway. Since the primary purpose of my test machines is testing autopilot and Intune app/profile deployments, I keep it lightweight with 2 vCPU, 4 GB, and a 40GB disk. Make your template disk:įirst, let’s create our initial VM disk image to use as our template. I ended up with a Windows 10 sysprepped VHDX file, and a PowerShell script that creates a VM with 2vCPU, 4GB RAM, connects the VM to my external vSwitch, and enables TPM (this part took me the longest to figure out). I tried to automate this and make the process as efficient as I could. When you’re testing configs for various tenants, its usually quicker to spin up a machines with a unique VM ID & serial number for testing. If you are constantly testing Intune and autopilot configurations, you probably use hyper-v on your local PC or have some form of virtualization to help accomplish this.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |