1 Reply Latest reply on Sep 19, 2018 8:41 AM by LucD

    Powershell to get Name, Hardware Version, Guest OS and Running OS

    Darwyn99 Novice

      Hi,

      I'm running into this issue:  https://kb.vmware.com/s/article/2092807 so I'm looking to get info on systems that includes the Name, Hardware Version, the Guest OS and the actual running OS.  I'm looking for systems that aren't up to date on hardware version and I'm also looking for systems that have a guest OS setting that is different than the actual running OS.  I've found this post:  https://communities.vmware.com/thread/512090 that almost gets me the info I need.  The powershell/cli is this:

      Get-VM | Sort | Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName") | Select -Property Name, @{N="Configured OS";E={$_.Config.GuestFullName}},  @{N="Running OS";E={$_.Guest.GuestFullName}} | Format-Table -AutoSize

      But I can't just put the version in there.  When I do, it is blank.  But when I just do a get-vm | select name, version, that works. 

      any help is appreciated. 

        • 1. Re: Powershell to get Name, Hardware Version, Guest OS and Running OS
          LucD Guru
          vExpertCommunity WarriorsUser Moderators

          Since you are working with the vSphere object VirtualMachine (due to the Get-View), you have to give the correct location Config.Version.

          And you have to add that path to the Property parameter on the Get-View cmdlet.

          Something like this

           

          Get-VM | Sort-Object -Property Name |

          Get-View -Property @("Name", "Config.GuestFullName", "Guest.GuestFullName", "Config.Version") |

            Select -Property Name,

          @{N = 'HWVersion'; E = {$_.Config.Version}},

          @{N = "Configured OS"; E = {$_.Config.GuestFullName}},

          @{N = "Running OS"; E = {$_.Guest.GuestFullName}} |

            Format-Table -AutoSize