8 Replies Latest reply on Feb 19, 2016 2:21 PM by jessem

    Guest OS confusion

    jessem Enthusiast

      Ok so I run RVTools and I know it pulls Guest OS from the vmx file (configuration file).

       

      On one VM, it's running Redhat and the vCenter summary tab shows Redhat. 

       

      However, the vmx file reports SLES Linux 11.  The vmx file has sles-11 via the RVTools report.  How can I get a report of the current OS that vCenter is showing.

       

      VM Name, Guest OS Running, datacenter, and cluster?

        • 1. Re: Guest OS confusion
          LucD Guru
          Community WarriorsvExpertUser Moderators

          When you create a VM you can specify  the OS, via the GuestId parameter on the New-VM cmdlet.

          But you can install whatever OS you want in the VM.

          Via the VMware Tools you can find the actual OS that was installed (the OSFullName property that is returned by the Get-VMGuest cmdlet).

           

          So you could something like this

           

           

          Get-VM |

          Select Name,

              @{N='OS';E={$_.Guest.OSFullName}},

              @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

              @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}}

           

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          • 2. Re: Guest OS confusion
            jessem Enthusiast

            Great, one more thing.  Can I also get the vmem and vcpu for each VM on this in a csv/excel file?

            • 3. Re: Guest OS confusion
              LucD Guru
              vExpertUser ModeratorsCommunity Warriors

              Sure, just add the properties to the Select-Object cmdlet.

               

              Get-VM |

              Select Name,NumCpu,MemoryMB,

                  @{N='OS';E={$_.Guest.OSFullName}},

                  @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

                  @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}} |

              Export-Csv report.csv -NoTypeInformation -UseCulture

              Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
              • 4. Re: Guest OS confusion
                jessem Enthusiast

                This is great LucD!  Do you know what property I can add the VM folder in vCenter and ESXi host to this?

                • 5. Re: Guest OS confusion
                  LucD Guru
                  Community WarriorsUser ModeratorsvExpert

                  You can find all properties of the returned objects from Get-VM in the VirtualMachine object.

                  Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                  1 person found this helpful
                  • 6. Re: Guest OS confusion
                    jessem Enthusiast

                    I tried the script and it doesn't work.

                     

                    Get-VM |

                    Select Name,NumCpu,MemoryMB,Folder,VMHost

                        @{N='OS';E={$_.Guest.OSFullName}},

                        @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

                        @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}} |

                    Export-Csv report.csv -NoTypeInformation -UseCulture

                     

                    When I run it from powercli, it outputs in the cmd box, name, cpu, memory, folder, host.  However, when I open up the csv file, I get this:

                     

                       

                    IsReadOnlyIsFixedSizeIsSynchronizedKeysValuesSyncRootCount
                    FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
                    FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
                    FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
                    • 7. Re: Guest OS confusion
                      LucD Guru
                      Community WarriorsvExpertUser Moderators

                      I suspect you might have forgotten a comma after VMHost

                      Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
                      1 person found this helpful
                      • 8. Re: Guest OS confusion
                        jessem Enthusiast

                        OMG, thanks.  You are a life saver.