Automation

 View Only
  • 1.  vm version

    Posted Jan 24, 2011 09:34 PM

    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?



  • 2.  RE: vm version

    Posted Jan 24, 2011 10:00 PM

    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



  • 3.  RE: vm version

    Posted Jan 24, 2011 10:01 PM

    This should get you started.

    $vm = Get-VM vmname

    $vm.version



  • 4.  RE: vm version

    Posted Jan 24, 2011 10:37 PM

    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



  • 5.  RE: vm version

    Posted Jan 25, 2011 02:23 AM

    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.



  • 6.  RE: vm version

    Posted Jan 25, 2011 05:03 AM

    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.



  • 7.  RE: vm version

    Posted Jan 25, 2011 12:33 PM

    Thanks

    this works alot faster and did the trick!



  • 8.  RE: vm version

    Posted Jan 25, 2011 01:16 PM

    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}



  • 9.  RE: vm version

    Posted Feb 03, 2011 03:54 AM

    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?