I would like to create a Windows virtual machine (clone) on GCP from an existing Windows virtual machine on GCP
And i would like to have the clone autojoin the domain.
I would like to create a Windows virtual machine (clone) on GCP from an existing Windows virtual machine on GCP
And i would like to have the clone autojoin the domain.
You can easily clone any VM instance on GCP by creating a snapshot, then creating the new instance from that snapshot.
With regards to making it auto join in a domain, it is an OS based operation and there is a lot of options you can find on the internet. One good option for windows is the unattended setup.
As Alex G said, you can clone the VM by creating a snapshot and creating a new image from that snapshot.
See: https://cloud.google.com/compute/docs/disks/create-snapshots
Adding a bit more on that, I would also say that you can use disk images instead of snapshots.
See: https://stackoverflow.com/a/50669424/1419213
For what concerns joining the instance to a domain, I would suggest you to use a Powershell command to join the domain as specified by Microsoft documentation here:
https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.management/add-computer?view=powershell-5.1
And see also: https://petri.com/add-computer-to-domain-powershell
These Powershell command(s) can then be executed automatically on the instance startup by using the 'windows-startup-script-ps1' metadata key in Compute Engine:
https://cloud.google.com/compute/docs/startupscript#providing_a_startup_script_for_windows_instances
You can use a GCP API call to remove the startup script once the machine has been joined successfully (see API tab here):
https://cloud.google.com/compute/docs/storing-retrieving-metadata#updatinginstancemetadata