Warning: Use at you own risk. No liabilities. Although the script checks i.e. should not overwrite stuff I don't guarantee. Make sure you have a backup.
You like PowerShell and are using Hyper-V and maybe need to:...
This set of scripts will create VMs on Hyper-V based on a golden image (i.e. sysprepped .vhdx) with the specific settings that you predefine in PShell config files.
I have been working with Hyper-V for years and created a lot of VMs over the time - either manual or automatically. It was blog posts like these:
OS: Windows Server 2016, Windows Server 2019, Windows Server 2022, Azure Stack HCI (22H2, 23H2) Components: Hyper-V with corresponding PowerShell module.
Works either launched locally or using PS remoting.
Choose a starting repository e.g. Scenario-Blueprint,....
Copy the selected repository's content to your Hyper-V system - e.g. c:\temp
Create a sysprep'ed .vhdx containing the Windows OS you want using e.g. CreateVhdxFromIso.ps1.
.\CreateVhdxFromIso.ps1 -IsoPath "D:\iso\Windows Server 2022\SERVER_EVAL_x64FRE_en-us.iso" -VhdxPath 'c:\images\W2k22.vhdx' -SizeBytes 80GB -ImageIndex 4
# you can use .iso files with OS from Microsoft.
# -ImageIndex 1 : is the first image in the install.wim
# -ImageIndex 1 : mostly is a Server Standard Core
# -ImageIndex 4 : mostly is a Server Datacenter with GUI
# Mount .iso and run Get-WindowsImage -ImagePath "X:\sources\install.wim" to find out what imageindex to choose.
Adjust the $GoldenImage variable in your copy of the e.g. CreateHypervVms.ps1 file to match the path from step 2.
# 1. Create a golden image and adjust these variables
$GoldenImage = "c:\images\W2k22.vhdx" # path to a sysprepped virtual hard disk (UEFI i.e. Gen2 VMs) to be used as a golden image
Make the $vmDirectoryPrefix variable of your copy of CreateHypervVms.ps1 point to the VMs final path destination.
$vmDirectoryPrefix = "c:\ClusterStorage\CSV1\createvms" # generic path where the VMs will be created - each VM gets its subfolder
Choose a complex default password for your $adminPassword variable of your copy of CreateHypervVms.ps1
# Provide a complex generic local admin pwd
$adminPassword = 'some0815pwd!' # use single quotes to avoid PS special chars interpretation problems (e.g. $ in pwd problems)
Define the Hyper-V details of the VMs to create by modifying your copy of 1_VMs.psd1. Open the file in a PowerShell scripting editor and read the comments.
Define the OS details of the VMs by modifying your copy of 2_UnattendSettings.psd1. Open the file in a PowerShell scripting editor and read the comments.
Define the Post installation steps of the VMs by modifying your copy of 3_PostInstallScripts.psd1. Open the file in a PowerShell scripting editor and read the comments.