PowerCLI

 View Only
  • 1.  PowerCLI guest os version

    Posted Dec 27, 2017 05:57 AM

    I am trying to get the CentOS Version by PowerCLI.

    I am using this cmdlt:

    Get-VM | Select-Object @{N="Name";E={$_.Guest.VM}},@{N="OS";E={$_.Guest.OSFullName}} | Format-Table

    It works perfect for Windows Server, but CentOS Server shows 「CentOS 4/5/6/7 (64bit)」

    I want to have which version the CentOS is running on.

    Does anyone know how to do it or if it is even possible...



  • 2.  RE: PowerCLI guest os version
    Best Answer

    Posted Dec 27, 2017 06:03 AM

    There  are 3 ways of getting the OS:

    • the OS you specified when you created the VM. This one is highly unreliable since you could for example install a Windows OS on a VM that you defined with a Linux OS
    • through the VMware Tools, which must be installed for this to work. The info is under the $vm.Guest property, i.e. $vm.Guest.OSFullName
    • by querying inside the guest OS with the Invoke-VMScript cmdlet. This is the most reliable method imho.

    For your CentOS VM, I would first check the $vm.Guest.OSFullName property, provided VMware Tools are installed.



  • 3.  RE: PowerCLI guest os version

    Posted Dec 27, 2017 08:24 AM

    Thank you LucD,

    the Invoke-VMScript worked for me.

    searching how to do it took me so long, but your

    advice took me only few minutes to get the answer

    big help, thank you



  • 4.  RE: PowerCLI guest os version

    Posted Mar 21, 2018 10:56 AM

    LucD,

    $vm.Guest.OSFullName seems stopped pulling the data, we use 6.0 u3d version and its VM HW and latest VM tools running.



  • 5.  RE: PowerCLI guest os version

    Posted Mar 21, 2018 11:30 AM

    For all VMs, or just some of them?