Enabling Hyper – V
Follow the steps in the below article to enable Hyper-V on your local machine:
https://learn.microsoft.com/en-us/virtualization/hyper-v-on-windows/quick-start/enable-hyper-v
Creating VM on Hyper V
Launch the Hyper-V manager.
Right Click on your laptop name and select “New.”

Follow the on-screen instructions.
Specify your VM Name


Choose Generation 2

Assign a minimum of 4 GB of RAM or more.

Connect to the Default Switch for internet access on VM

Select “Attach a virtual hard disk later” and click on next

Confirm the summary and click finish.

Click on the settings tab on the right window of the VM you newly created.
Go to the securities tab.
Check on “enable secure boot” and “enable trusted platform module”.
Leave the template settings to default which is “Microsoft Windows”.
Make sure you have done all the right settings and click on OK.

As an optional step you can reduce the number of virtual processors to two

Select scsi controller.
Select Hard Drive and click on add.

Select virtual hard drive and click on new.

Choose the disk type as fixed size.

Specify an appropriate name for your disk.

Provide a minimum of 20GB hard disk if not more.

Confirm the details in the summary and click on finish.

On the main window you would see the disk is created and the disk path is populated.
Copy the path for future use

now we should add a DVD drive Under SCSI controller.

Click on the image file radio button.
browse and choose the ISO image you want to install.
Click on OK

You can see your boot order under the firmware.

Make sure that the DVD drive is on top of the boot order list.
You can do that by selecting DVD drive and clicking on the “move up” button.
Once it is set click on OK
Click on the start button from the actions window to start the machine and then click on connect once it is up and running.
Follow the on-screen instructions from here and click on the screen to boot from DVD.

Choose the appropriate OS version (in this case we are choosing Windows 10 enterprise) and click on next

Check and accept the license agreements and click on next.

Select custom install windows only for fresh install

Make sure there are no partitions and click on next.

The installation will take a few minutes.
Please follow the installation procedure as it might ask you for a few inputs like the username password etc.

Follow the next series of onscreen instructions and finish the installation.
Enabling Remote Connection and disabling NLA
Once the machine is up and you are connected, go to Windows > Run > Remote Desktop Settings
Enable Remote Desktop by turning on the toggle as shown below.
Click on Advanced Settings

Optionally, you can also disable NLA in the Advanced Settings window
Convert the disk into a VHD
Follow the instructions in the following article to convert the vhdx to vhd type.
https://learn.microsoft.com/en-us/azure/virtual-machines/windows/prepare-for-upload-vhd-image#use-hyper-v-manager-to-convert-the-disk
Uploading and importing the image on GCP
Upload the VHD you just created on the GCP S3 bucket.
After the upload is completed, run the following SDK command to import into a GCP custom image.
Please note the flag “UEFI_COMPATIBLE" which should be mentioned for UEFI enabled images.
> gcloud compute images import win10-21h1-gen2 --os=windows-10-x64-byol --source-file="gs://customer-success-images/win10-21h1-gen2.vhd" --project "training-294104" --network=wsbeta-gcp-vpc --subnet=wstraining-usc1 --guest-os-features="UEFI_COMPATIBLE"

Deploying a VM from the newly imported base image:
Create an instance by using the gcloud compute instances create command, and use the --image and --image-project flags to specify the image name and the project where the image resides:
gcloud compute instances create [INSTANCE_NAME] --image [IMAGE] --image-project [IMAGE_PROJECT]
Example:
gcloud compute instances create win10-21h1-gen2v1 --project=training-294104 --zone=us-east5-c --machine-type=n2-standard-2 --network-interface=network-tier=PREMIUM,stack-type=IPV4_ONLY,subnet=wstraining-useast5 --maintenance-policy=TERMINATE --provisioning-model=STANDARD --service-account=38893795949-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --enable-display-device --create-disk=auto-delete=yes,boot=yes,device-name=win10-21h1-gen2v1,image=projects/training-294104/global/images/win10-21h1-gen2,mode=rw,size=127,type=projects/training-294104/zones/us-east5-c/diskTypes/pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring --labels=goog-ec-src=vm_add-gcloud --reservation-affinity=any
Please note that in the above example, we enabled vTPM and Shielded-integrity-monitoring on this VM.
Gcloud Article - https://cloud.google.com/compute/docs/instances/create-start-instance#creating_an_instance_from_a_custom_image

Installing Google Guest Environment packages:
Once the VM is deployed login and Install the core packages google-compute-engine-windows, google-compute-engine-metadata-scripts,google-compute-engine-sysprep, and google-compute-engine-vss.
googet -noconfirm install google-compute-engine-windows google-compute-engine-sysprep google-compute-engine-metadata-scripts google-compute-engine-vss
Additionally, you should also install the Network Drivers for the NIC – NetKVM Drivers and Optionally GGA Display Drivers in case you are enabling “Use Display Adapter” (Refer: https://cloud.google.com/compute/docs/instances/enable-instance-virtual-display) on the VM Edit page on Gcloud console. Give the following command to install the drivers.
Googet install google-compute-engine-driver-netkvm
Googet install google-compute-engine-driver-gga.googet
C:\windows\system32> googet -noconfirm install google-compute-engine-driver-netkvm google-compute-engine-driver-vioscsi google-compute-engine-driver-pvpanic google-osconfig-agent google-compute-engine-driver-balloon google-compute-engine-driver-gga
GCloud Article: https://cloud.google.com/compute/docs/images/install-guest-environment
Install Workspot Template Agent
Please follow the regular steps to install the Workspot Template Agent and Configure it. Along with it, please proceed with installing your applications and making the customer changes that this template is required to have.
Creating Template:
Once the agent is registered and other customizations are done as per requirement, we must now convert the VM into a template, for this we should first deploy an Image from the template VM Disk and then create an Instance Template.
Create an Image from the template disk
In the Google Cloud Console, Click on Images on the left window and click on Create an image.
SDK Command:
gcloud compute images create win10-gen2-ti \
--project=training-294104 \
--family=windows \
--source-disk=win10-21h1-gen2 \
--source-disk-zone=us-east5-c \
--storage-location=us

Create an Instance Template from this Template image:
Create an instance Template from this new template image by using the gcloud compute instances create command, and use the --image and --image-project flag to specify the image name and the project where the image resides:
gcloud compute instance-templates create [INSTANCE-TEMPLATE_NAME] –image [IMAGE] –image-project [IMAGE_PROJECT]
Make sure you provide the Instance Template name exactly as that of the Template VM
This is important because control would not be able to register it unless the name is the same.
Example:
C:\Program Files (x86)\Google\Cloud SDK>gcloud compute instance-templates create win10-21h1-gen2v1 --project=training-294104 --machine-type=n2-standard-4 --network-interface=subnet=wstraining-usw1,no-address --maintenance-policy=TERMINATE --provisioning-model=STANDARD --service-account=38893795949-compute@developer.gserviceaccount.com --scopes=https://www.googleapis.com/auth/devstorage.read_only,https://www.googleapis.com/auth/logging.write,https://www.googleapis.com/auth/monitoring.write,https://www.googleapis.com/auth/servicecontrol,https://www.googleapis.com/auth/service.management.readonly,https://www.googleapis.com/auth/trace.append --region=us-west1 --create-disk=auto-delete=yes,boot=yes,device-name=win10-21h1-gen2v1,image=projects/training-294104/global/images/win10--gen2v1-t,mode=rw,size=127,type=pd-balanced --no-shielded-secure-boot --shielded-vtpm --shielded-integrity-monitoring
