View Only
  • 1.  Get Guestos trough Powercli

    Posted Nov 22, 2013 01:38 PM

    Hi all,

    I wrote below script to get all Vm's in my Vcenters that don't have vmware tools installed. i am trying to include the vm's / guests operating system into the csv output as well and can't seem to figure out how to do this. So if someone could help me out that would be great!

    New-VIProperty -Name ToolsVersionStatus -ObjectType VirtualMachine ` -ValueFromExtensionProperty 'Guest.ToolsVersionStatus' ` -Force

    New-VIProperty -Name ToolsVersion -ObjectType VirtualMachine ` -ValueFromExtensionProperty '' ` -Force

    $vcenter=Read-Host "Please enter VCenter to run this report on"

    $csvlocation=Read-Host "Please enter a location for the CSV logfile"

    Connect-ViServer $vcenter

    $notools = Get-VM | where-Object {$_.ToolsVersionStatus -eq "guestToolsNotInstalled"}

    if ( $notools -eq $null) {



    else {

    Get-VM $notools | Select Name, Version, ToolsVersion, ToolsVersionStatus, powerstate, vmhost, | Export-Csv -NoTypeInformation -UseCulture $csvlocation\$vcenter.csv


    Disconnect-VIServer $vcenter -Confirm:$False

    Thanks in advance:smileyhappy:

  • 2.  RE: Get Guestos trough Powercli
    Best Answer

    Posted Nov 22, 2013 10:13 PM

    Hello, -

    You can access such info via a sub-property in the Guest property of the VirtualMachine object.  So, to continue with your New-VIProperty usage, you could add another new VIProperty as follows, then add that property to the Select statement:

    New-VIProperty -Name GuestFullName -ObjectType VirtualMachine -ValueFromExtensionProperty 'Guest.GuestFullName' -Force

    Then just add "GuestFullName" to the list of properties in your Select statement, and you should be good.  That do it for you?

  • 3.  RE: Get Guestos trough Powercli

    Posted Nov 25, 2013 10:42 AM

    Thanks for the help, this sort off did the trick. Some vm's are not showing their os version but that is not because of the new vi property.

    Going to try and figure out why that is now :smileyhappy:

  • 4.  RE: Get Guestos trough Powercli

    Posted Nov 26, 2013 09:51 PM

    Hello, mkool89-

    Alright, good, glad to help.  As for VMs not showing their OS version -- that is reliant upon VMware Tools running in the guest.  So, if Tools aren't running (or haven't been for a while), you might see the symptom of no data for that Guest OS property.  Do the VMs in your example that return no OS info also not have Tools running?

  • 5.  RE: Get Guestos trough Powercli

    Posted Nov 27, 2013 11:35 AM


    I didn't know that the property was dependandt on vmwaretools being installed. It makes sense now that it doesn't display since my script displays all VM's withouth tools installed! At least i learned something :smileyhappy: !

    I have one more question: is there a place where i can see al the viproperty's that can be added? I am having dificulties with finding  properties and what they do.


  • 6.  RE: Get Guestos trough Powercli

    Posted Dec 04, 2013 03:10 PM


    Yesss, good to hear (I learn at least one thing every day!).

    As for a place to see what VIProperties can be added:  it's really about what properties are available.  The vSphere API reference documentation shows all of the properties/methods that you can leverage.  vSphere Web Services SDK:  And, in particular, the vSphere API Reference:

    Check those out, and made whatever VIProperties you want!  Meanwhile, LucD (of course) has a nice collection of VIProperties that he and others have written:  Check it out.

  • 7.  RE: Get Guestos trough Powercli

    Posted Mar 25, 2014 01:37 PM


    Im trying to do something similar, but im running into some problems tho.

    First of all, i would like to just count how many VM's are running linux as guest OS, this i have done by using this command:

    Get-VM | Select-Object Name, PowerState, NumCpu, MemoryMB, ProvisionedSpaceGB, Guest | Where-Object {$_.Guest.OSFullName -like "*Linux*"}

    And i get list back of 6 VM's but when i go to my vSphere Client and list all VM's, filter them on GuestOS containing Linux, i have 14 VM's

    Why are the Powershell CLI only counting 6, when there are 14 in total? Does this also have something to do with vmWare Tools not running on the VM's? or is this something else?


    I solved it. I belive its because the above line does not look at what the VM's OS have been selected to be the time it was build. But that is only what i belive :smileyhappy:

    I solved it with this instead:

    $vms = get-vm

    foreach($vm in $vms) {

    $vmview = $vm | get-view

    if ($vmview.Summary.Config.GuestFullName -like "*Windows*") {$wincount++}



    This will count the real amount of VM's that have some kind of Windows OS configured.

    Message was edited by: GlenTrust