PowerCLI

 View Only
Expand all | Collapse all

How to get all VirtualMachineGuestOsIdentifier over PowerCLI

  • 1.  How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 05, 2016 03:51 PM

    Hi

    I would like to get a list of all VirtualMachineGuestOsIdentifier within PowerCLI.

    Smth like this:

    https://www.vmware.com/support/developer/converter-sdk/conv61_apireference/vim.vm.GuestOsDescriptor.GuestOsIdentifier.ht…

    I tried this:

    (get-vm | get-vmguest).GuestID | sort | unique

    This Shows all IDs but only from existing VMs, but i want all of it :-)

    I am trying to get the list over the Type "GuestID", but I am not able to do it.

    With this line i'm getting the TypeName:

    Get-Vm <servername> | get-vmguest | get-member guestid

    => TypeName: VMware.VimAutomation.ViCore.Impl.V1.VM.Guest.VMGuestImpl

    Now, I have no idea how to go further from this.

    Can you please help me? Or is there a better way?

    Thank you very much :smileyhappy:



  • 2.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI
    Best Answer

    Posted Feb 05, 2016 04:53 PM

    If you're at least on PowerShell v3, you can do

    [VMware.Vim.VirtualMachineGuestOsIdentifier].GetEnumValues()



  • 3.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 07:41 AM

    Hi LucD

    Thank you very much, exactly what I was looking for :smileyhappy:

    How did you find out this [VMware.Vim.VirtualMachineGuestOsIdentifier] ?

    Is there also a way to get the FullName?



  • 4.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 08:34 AM

    The API Reference and some PowerShell/.Net knowledge.

    In a VirtualMachine object, this OS id is stored in the VirtualMachineConfigInfo object under the guestId property.

    The API Reference tells me that the property contains a value from the VirtualMachineGuestOsIdentifier‌ enumeration.

    In the PowerCLI framework these enumerations are mapped.

    From within PowerShell you can get all values for an enumeration with the GetEnumValues method, which is defined on the System.Type since .Net4



  • 5.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 09:35 AM

    thank you for the Explanation, I understand now, how it works.

    I can see the Property guestFullName from the Object "VirtualMachineConfigInfo".

    But this Property does not contain any enumerations, am I right?

    Is there another way to get the description for this enumeration VirtualMachineGuestOsIdentifier ?



  • 6.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 09:50 AM

    That is correct.

    The value for guestFullName is obtained via the VMware Tools from within the guest OS.

    For vSphere that is just a [string], no enumeration.

    Not sure what you mean with that last question ?



  • 7.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 09:56 AM

    I would like to have the VirtualMachineGuestOsIdentifier but also the descripton of the ID within PowerCLI.

    As an example, I want this Info: windows7Server64Guest => Windows Server 2008 R2 (64 bit)

    And this for each OSIdentifier.

    Hope it's clear now

    Thx for your time :smileyhappy:



  • 8.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 08, 2016 05:21 PM

    I'm afraid there is no enumeration for that property.

    It's a string that comes from within the guest OS, obtained through the VMware Tools.



  • 9.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 09, 2016 06:41 AM

    Ok, what a pity :smileysad:

    Thank you very much for your help



  • 10.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Sep 03, 2019 05:14 PM

    Thank you so much, Perfect answer



  • 11.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 09, 2016 04:23 PM

    $viObjVmHost = Get-VMHost -Name "whatever"

    $viewObjEnvBrowser = Get-View -Id (Get-View -Id $viObjVmHost.ExtensionData.Parent).EnvironmentBrowser

    $vmxVer = ($viewObjEnvBrowser.QueryConfigOptionDescriptor() | Where-Object {$_.DefaultConfigOption}).Key

    $osDesc = $viewObjEnvBrowser.QueryConfigOption($vmxVer,$viObjVmHost.ExtensionData.MoRef).GuestOSDescriptor

    Maybe that will give you what you are seeking. It is based on a given host and VM version. I believe it is what gets used by the GUI when deploying a new VM.



  • 12.  RE: How to get all VirtualMachineGuestOsIdentifier over PowerCLI

    Posted Feb 10, 2016 07:43 AM

    Wow, perfect! You are a genius

    It works like a charm :-)

    Thank you both for the great support