Change BIOSGUID in Hyper-V machines
Using templated virtual machines on hyper-v comes with some issues if you need to ensure that each VM has a unique identity. This guide will show how you'll assign a unique identity for linux VMs.
A thing most people don't know is that when importing virtual machines hyper-v also imports base configuration like BIOSGUID - which is somehow expected, as you won't want to change anything on your system if you export and import again. In case you're exporting and importing for deployment purpose you might want to change this identifier. This is especially relevant if you are running virtual machines on larger scale and you're using templated virtual machines that are deployed several times.
Why change BIOSGUID?
Operating systems often rely on some hardware fingerprint to generate a unique id of the host. Linux for example generates product_uuid based on the BIOSGUID (accessible via /sys/class/dmi/id/product_uuid). If you're running workloads like kubernetes that require unique identifiers of each host, you might avoid using templated VMs or just reset the identifier for a particular VM.
How to change the BIOSGUID?
Modifying these kind of settings can be done at any stage of the virtual machine (no need to reinstall, redeploy, etc.) - the VM has just to be turned off, so you'll need to plan some brief downtime for the adjusment.
The following script will use WMI to adjust the virtualmachine settings and apply just a new, randomly assigned GUID.
That's all you need to do - starting the VM will show a new BIOSGUID, so that you can keep using your images without having issues on duplicate identifiers!