VMware Cloud Community
twindude
Enthusiast
Enthusiast

vm version

is there a way to pull out the vm version (4, 7)?

i have tried vm-view but can't seem to get the syntax right..

can i do this with  ExtensionData string?

0 Kudos
8 Replies
ThompsG
Virtuoso
Virtuoso

Hi,

Try the following:

$vm = Get-VM -Name <Name of your VM>

$vmv = $vm | Get-View

$vmv.Config.Version

This should return either vmx-04 or vmx-07 depending on the hardware version of the virtual machine.

Kind regards.

Message was edited by: ThompsG to add code frame

0 Kudos
Zsoldier
Expert
Expert

This should get you started.

$vm = Get-VM vmname

$vm.version

Chris Nakagaki (中垣浩一)
Blog: https://tech.zsoldier.com
Twitter: @zsoldier
0 Kudos
twindude
Enthusiast
Enthusiast

OK..

so i have this running and i would like to add the hardware version to this excel page: is this possible?

#DR Cluster

#place your SQL cluster name in place of "DR" below

Get-Cluster "DR" |

Get-VM | Select Name,

@{N="Tools version";E={$_.ExtensionData.Guest.ToolsVersion}},

@{N="Tools version status";E={$_.ExtensionData.Guest.ToolsVersionStatus}},

@{N="Tools running status";E={$_.ExtensionData.Guest.ToolsRunningStatus}} |

Export-Csv "C:\VM-Info_DR.csv" -NoTypeInformation

0 Kudos
ThompsG
Virtuoso
Virtuoso

Hi,

Yes it is possible. Will look something like this:

#DR Cluster
#place your SQL cluster name in place of "DR" below

Get-Cluster "DR" |

Get-VM | Select Name,

@{N="Tools version";E={$_.ExtensionData.Guest.ToolsVersion}},
@{N="Tools version status";E={$_.ExtensionData.Guest.ToolsVersionStatus}},
@{N="Tools running status";E={$_.ExtensionData.Guest.ToolsRunningStatus}},
@{N="Hardware version";E={$_.version}} |
Export-Csv "C:\VM-Info_DR.csv" -NoTypeInformation

Kind regards.

0 Kudos
mattboren
Expert
Expert

Hello, @twindude-

Yes, @ThompsG's reply should work just fine.

For speed's sake, though, you could use the .Net View objects returned from Get-View instead of using Get-VM.  The speed difference, as documented in many other posts, is remarkable.  In a cluster in a test lab with about 150 VMs, the Get-VM method took about sixty-five (65) seconds, whereas the Get-View route was about three (3) seconds.

Using Get-View, it would look like:

Get-View -ViewType VirtualMachine -Property Name,Guest,Config.Version -SearchRoot (Get-View (Get-Cluster "DR")).MoRef | Select Name,
@{N="Tools version";E={$_.Guest.ToolsVersion}},
@{N="Tools version status";E={$_.Guest.ToolsVersionStatus}},
@{N="Tools running status";E={$_.Guest.ToolsRunningStatus}},
@{N="vHardware Version";E={$_.Config.Version}} | Export-Csv "C:\VM-Info_DR.csv" -NoTypeInformation

20-times faster to run?  I'm there.

Enjoy.

0 Kudos
twindude
Enthusiast
Enthusiast

Thanks

this works alot faster and did the trick!

0 Kudos
twindude
Enthusiast
Enthusiast

in the Get-view command

how do i see the Nic type

also is there a list somewhere for these functions - when i google get-view cmdlet a few items but looking for properties of VMs

i tried

@{N="vNIC type";E={$_.Guest.Nics | %{$_.Device.Type}

0 Kudos
mattboren
Expert
Expert

Hello, @twindude-

Well, the way that I found to get NIC types of "flexible, e1000, etc." is fairly slow by comparison to the code above, as it depends on the Get-NetworkAdapter cmdlet, instead of using only .Net view objects.  But, it looks something like:

## gets the "flexible, e1000" etc. types, but slow due to having to do a Get-NetworkAdapter and getting a VI object
Get-View -ViewType VirtualMachine -Property Name,Guest,Config.Version -SearchRoot (Get-View (Get-Cluster "DR")).MoRef | Select Name,     @{N="Tools version";E={$_.Guest.ToolsVersion}},     @{N="Tools version status";E={$_.Guest.ToolsVersionStatus}},     @{N="Tools running status";E={$_.Guest.ToolsRunningStatus}},     @{N="vHardware Version";E={$_.Config.Version}},     @{N="vNIC(s) type(s)";E={(Get-NetworkAdapter -VM $_.Name | %{$_.Type}) -join ","}}

Using only .Net view objects returns values for NICs like "VirtualPCNet32" and the likes.  It looks something like:

Get-View -ViewType VirtualMachine -Property Name,Guest,Config.Version,Config.Hardware.Device -SearchRoot (Get-View (Get-Cluster "DR")).MoRef | Select Name,
    @{N="Tools version";E={$_.Guest.ToolsVersion}},
    @{N="Tools version status";E={$_.Guest.ToolsVersionStatus}},
    @{N="Tools running status";E={$_.Guest.ToolsRunningStatus}},
    @{N="vHardware Version";E={$_.Config.Version}},
    @{N="vNIC(s) type(s)";E={$viewTmpVM = $_; $_.Guest.Net | %{$intDevIDKey = $_.DeviceConfigId; ($viewTmpVM.Config.Hardware.Device | ?{$_.Key -eq $intDevIDKey}).GetType().Name}}}

...though, that seems to have a dependency on the VM being powered on(?).

How do those do for you?

0 Kudos