Get the operating system of a GCP instance without pre-defined features

634 Views Asked by At

How can I get a GCP Instance operating system type?

I need to be able to tell if an instance os type is Linux or Windows using the API / .Net Client SDK.

So far I found answers such as get-guest-attribute: https://cloud.google.com/compute/docs/metadata/manage-guest-attributes

and os-config inventory: https://cloud.google.com/compute/docs/instances/view-os-details

but both require to have options enabled on the instance in advance, whereas in my case I cannot enable any new option/setting/attribute on the instance.

Is there a way to get the instance operating system without enabling any feture in the instance in advance? even if not the full OS Type (like Linux Ubuntu 20.04 or Windows Server 2019) but just a hint (like Linux or Windows)?

1

There are 1 best solutions below

1
On
As per Maninder Chhabra, there is a command gcloud compute instances os-inventory describe VM-NAME to get the OS configs only when VM is in RUNNING state.