Pages: [1]
Print
Author Topic: List Guest OS information  (Read 4488 times)
dma0211
Newbie
*
Posts: 15


View Profile
« on: February 25, 2009, 03:40:31 PM »

Code:
$report = @()
get-vm | Sort Name -Descending | % {
  $vm = Get-View $_.ID
    $vms = "" | Select-Object VMName, GuestVersion
    $vms.VMName = $vm.Name
$vms.GuestVersion = $vm.guest.guestfullname
$report += $vms
}
$report | Export-Csv "C:\vm_GuestVersion.csv" -NoTypeInformation
« Last Edit: February 26, 2009, 07:27:01 AM by esarakaitis » Logged
esarakaitis
Administrator
Sr. Member
*****
Posts: 256


8223109 sack57@hotmail.com littleking57 rootinfortwayne
View Profile WWW Email
« Reply #1 on: February 26, 2009, 07:27:33 AM »

very nice, i added the code tags around your script
Logged
KristianW
Newbie
*
Posts: 32


View Profile
« Reply #2 on: March 25, 2009, 09:14:35 AM »

Very cool, and useful script.

However, I am somewhat puzzled over the output.
Some of my VMs turn up without GuestOS information.

Anyone who knows where this information i collected from?
The VMs have (most of them) vmware-tools installed and running.
Everyone have had the correct OS setting put in VC, and it is showing correct in VC.

As of now 1 out of 5 turns up with unknown OS.


-K
Logged
KristianW
Newbie
*
Posts: 32


View Profile
« Reply #3 on: March 26, 2009, 09:43:35 AM »

Got a response from a VMware dude. The PowerShell script digs this information from VC, who gets it in the first place from each VM. Either through vmware-tools, or through the binary instructions the guest uses. This information is "read" on VM reboot or if any changes are made to the vCenter-service.

According to him, sometimes this operation is quite slow.

What bothers me is that the VMs have been active for quite some time now - and should be updated.

Update: According to VMware the information could take 1 month to get populated if you have more than 600 VMs running.
« Last Edit: April 02, 2009, 08:35:58 AM by KristianW » Logged
KristianW
Newbie
*
Posts: 32


View Profile
« Reply #4 on: April 02, 2009, 09:35:28 AM »


btw: Could anyone with knowledge (since I am missing it) edit the script to also include the host? I have tried and failed it seems.
Logged
ewannema
Administrator
Newbie
*****
Posts: 33


View Profile WWW
« Reply #5 on: April 02, 2009, 12:26:30 PM »

Below is a simple modification of the script to do what you are asking.  I will also post variations.

Code:
$report = @()
get-vm | Sort Name -Descending | % {
    $vm = Get-View $_.ID
    $vms = "" | Select-Object VMhost, VMName, GuestVersion
    $vms.VMName = $vm.Name
$vms.GuestVersion = $vm.guest.guestfullname
    $vms.VMhost = (Get-View $vm.Runtime.Host).Name
$report += $vms
}
$report | Export-Csv "C:\vm_GuestVersion.csv" -NoTypeInformation
Logged
ewannema
Administrator
Newbie
*****
Posts: 33


View Profile WWW
« Reply #6 on: April 02, 2009, 12:32:34 PM »

No view step.  Simpler and faster.

Code:
$report = @()
get-vm | Sort Name -Descending | % {
    $vm = "" | Select-Object VMhost, VMName, GuestVersion
    $vm.VMName = $_.Name
$vm.GuestVersion = $_.guest.OSFullname
    $vm.VMhost = $_.Host.Name
$report += $vm
}
$report | Export-Csv "C:\vm_GuestVersion.csv" -NoTypeInformation
« Last Edit: April 02, 2009, 01:22:50 PM by ewannema » Logged
ewannema
Administrator
Newbie
*****
Posts: 33


View Profile WWW
« Reply #7 on: April 02, 2009, 01:22:05 PM »

If you need the view of the VM to get some advanced information you can do it slightly quicker using the following outline.  There is no need for it in this case, but I wanted to provide something similar to what has been done.

Code:
$report = @()
foreach ($vmView in (Get-View -ViewType VirtualMachine))
{
    $report += $vmView | Select-Object @{Name="VMHost"; Expression={(Get-View $vmView.Runtime.Host).Name}},
                                       @{Name="VMName"; Expression={$_.Name}},
                                       @{Name="GuestVersion"; Expression={$vmView.Guest.GuestFullName}}
}
$report | Sort-Object VMName -Descending | Export-Csv "C:\vm_GuestVersion.csv" -NoTypeInformation
Logged
Pages: [1]
Print
Jump to: