allencrawford
Enthusiast
Enthusiast

problems obtaining guest OS

Jump to solution

Hello,

I need to be able to do a query on Windows 2003 VMs that are using the BusLogic SCSI adapter. However, I'm having a problem just getting the OS of each guest. Many guests (seems to be about 800 out of our 1200 guests) return a null value (I'd say that under 10 of these are powered off). I've tried this with both the 1.0 version of the VI Toolkit and also just upgraded to 1.5 to verify it wasn't fixed. Then again, I'm not 100% sure it is a problem with the toolkit. Anyway, here's what I've tried so far.

First, I found a good VM (vm1) and a bad VM (vm2). I created two variables:

$vm1 = Get-VM vm1name
$vm2 = Get-VM vm2name

Then I simply tried to enumerate the Guest.OSFullName property of each VM:

$vm1.Guest.OSFullName <-- returned Microsoft Windows Server 2003, Standard Edition (32-bit)
$vm2.Guest.OSFullName <-- returned nothing

Other "guest" properties seem fine as evidenced in the following output:

"$vm2.Guest" returns:

State          IPAddress            OSFullName
-----          ---------            ----------
Running        {1.2.3.4}

The only other thing I noticed (and I'm going to file an SR for this issue when I'm back in the office on Wednesday) is that if you view all the VMs in the VI Client and sort by Guest OS, there are a lot that just say "Unknown". I've noticed this back on 2.0/3.0 and now I'm running 2.5 U3 and 3.5 U3 everywhere. If you simply edit the settings of the VM and click OK (without making any changes to anything) it'll fix the "Unknown" Guest OS. If you click on the "Options" tab of the edit VM settings section, it shows the correct Guest OS there. However, clicking OK after clicking that tab causes an error message of something about not being able to change that setting in the current state (powered on). Regardless, at first I thought all the unknowns explained my missing Microsoft VMs, but there's just over 100 VMs or so that are listed as unknown, so I'm still way short.

Finally, I searched this discussion topic on the forums and learned about the Get-VMGuest cmdlet which I've somehow managed to never notice before. So, I tried the following:

$vm2 | Get-VMGuest

And got the same results as above (shows its power state and IP address, but no OS type). VM1 works just fine with the above code.

Does anyone have any ideas on this? I've even buried down and used Get-View and pulled the .Guest.GuestFullName property out and it is blank as well.

0 Kudos
1 Solution

Accepted Solutions
admin
Immortal
Immortal

Hi Allen,

I've never experienced tools that are so far out of date that you don't get a guest OS, but I wouldn't be surprised by it. You should always be able to get the tools version number anyway (although not out of Get-VMGuest in this release).

There is an important difference between these guests though, the guest that VMware Tools reports is the actual guest OS. The guest you get from Get-VM or Config.GuestFullName is the value that is set when creating the VM. This value may not be the same as the actual guest. For example, I could create a VM, select Windows 2003, then install Redhat on it. In this case Get-VM would report the VM as being a Windows VM whereas tools would report it (properly) as Redhat.

In general, use tools when you can. If you're not getting data from tools it may be wrong.

View solution in original post

0 Kudos
7 Replies
RobMokkink
Expert
Expert

Allen,

You should use the get-view method, like so



$vm1 = get-vm test | get-view


echo $vm1.config.guestfullname


allencrawford
Enthusiast
Enthusiast

Interesting. I did try the Get-View method, but instead of echoing out what you did, I tried:

$vm1.Guest.GuestFullName

Trying Config.GuestFullName works fine.

I've also since learned that apparently VMware Tools needs to be up-to-date (or at least more current than most of ours are running) for the Get-VMGuest info to display the OS (or any of the other methods I was originally trying in my first post). I tested it out on a couple VMs in the test lab and sure enough, all the methods report the OS fine now.

So, two more questions then:

1) What good is Get-VMGuest if it doesn't always report the OS (since VMware Tools will likely perpetually be out of date)?

2) What is the difference in all these different methods of obtaining the guest OS? I count about four ways to obtain the guest OS information:

$vm1 = Get-VM vm1name
$vm1.Guest.OSFullName

- or -

$vm1 = Get-VM vm1name
$vm1 | Get-VMGuest

- or -

$vm1 = Get-VM vm1name
$vmview1 = $vm1 | Get-View
$vmview1.Guest.GuestFullName

- or -

$vm1 = Get-VM vm1name
$vmview1 = $vm1 | Get-View
$vmview1.Config.GuestFullName

Just mainly trying to figure out the most foolproof way of doing this in the future and also trying to learn what the differences are.

Thanks a lot for the help.

0 Kudos
RobMokkink
Expert
Expert

There are more ways to get certain properties.

What i like to do when i develop script is:



$a = get-vm test | get-view


Then echo $a en browse through the properties and find out the best way to get the info you need.

0 Kudos
admin
Immortal
Immortal

Hi Allen,

I've never experienced tools that are so far out of date that you don't get a guest OS, but I wouldn't be surprised by it. You should always be able to get the tools version number anyway (although not out of Get-VMGuest in this release).

There is an important difference between these guests though, the guest that VMware Tools reports is the actual guest OS. The guest you get from Get-VM or Config.GuestFullName is the value that is set when creating the VM. This value may not be the same as the actual guest. For example, I could create a VM, select Windows 2003, then install Redhat on it. In this case Get-VM would report the VM as being a Windows VM whereas tools would report it (properly) as Redhat.

In general, use tools when you can. If you're not getting data from tools it may be wrong.

View solution in original post

0 Kudos
Automaton
Contributor
Contributor

Is there a way to get the guest OS for all VM's at once? I'm generating a VM inventory report in CSV format using powershell. Here is what I have so far:

$datastoreExp = @{N="Datastore"; E={ ($_ | get-datastore | select-object -first 1).Name }}

$ClusterName = @{N="Cluster"; E={ ($_ | get-cluster | select-object -first 1).Name }}

$GuestOSName = @{N="Guest OS"; E={ ($_ | get-vm | select-object -first 1).Name }}

get-vm | select Name, memorymb, numcpu, Host, $datastoreExp, $ClusterName |export-csv c:\vi_inv.csv

This gives me some good stuff, but I want to add guest OS.

0 Kudos
allencrawford
Enthusiast
Enthusiast

Thanks for the info. I'd definitely prefer to use the info coming from VMware Tools, but in this case, I guess I'll have to trust the other setting. It should be pretty accurate since everything is built from a template or P2V'd, but I guess I'll have to write something in my scripts that really matter to account for a NULL value and to fall-back on the .Config.GuestFullName value I guess. In this particular case, I'm just trying to find Windows 2003 VMs with BusLogic adapters, so it should be close enough. If only VMware Converter defaulted to LSI Logic (the adapter VMware recommends for Windows 2003) instead of BusLogic on a P2V, that'd save me this work in the first place.

0 Kudos
srinivasaddagat
Contributor
Contributor

&gt;Is there a way to get the guest OS for all VM's at once? I'm generating

a VM inventory report in CSV format using powershell. Here is what I

have so far:

You may use below, it worked perfectly fine for me.

=====

Connect-VIServer &lt;vc server name &gt;

$report = @()

$vm = Get-VM

foreach ($vmconfig in $vm)

{

$vmview = $vmconfig | Get-View

$row = "" | select VMName, OSType, NumberOfCPU, MemoryMB, PowerState, VMToolsStatus

$row.VMName = $vmconfig.name

$row.OSType = $vmview.Config.GuestFullName

$row.NumberOfCPU = $vmconfig.NumCpu

$row.MemoryMB = $vmconfig.MemoryMB

$row.PowerState = $vmconfig.PowerState

$row.VMToolsStatus = $vmview.Guest.Toolsstatus

$report += $row

}

$report | Export-Csv "&lt;location of csv file" -noTypeInformation

======

0 Kudos