VMware Cloud Community
jessem
Enthusiast
Enthusiast
Jump to solution

Guest OS confusion

Ok so I run RVTools and I know it pulls Guest OS from the vmx file (configuration file).

On one VM, it's running Redhat and the vCenter summary tab shows Redhat. 

However, the vmx file reports SLES Linux 11.  The vmx file has sles-11 via the RVTools report.  How can I get a report of the current OS that vCenter is showing.

VM Name, Guest OS Running, datacenter, and cluster?

Reply
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Sure, just add the properties to the Select-Object cmdlet.

Get-VM |

Select Name,NumCpu,MemoryMB,

    @{N='OS';E={$_.Guest.OSFullName}},

    @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

    @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}} |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

Reply
0 Kudos
8 Replies
LucD
Leadership
Leadership
Jump to solution

When you create a VM you can specify  the OS, via the GuestId parameter on the New-VM cmdlet.

But you can install whatever OS you want in the VM.

Via the VMware Tools you can find the actual OS that was installed (the OSFullName property that is returned by the Get-VMGuest cmdlet).

So you could something like this

Get-VM |

Select Name,

    @{N='OS';E={$_.Guest.OSFullName}},

    @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

    @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jessem
Enthusiast
Enthusiast
Jump to solution

Great, one more thing.  Can I also get the vmem and vcpu for each VM on this in a csv/excel file?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, just add the properties to the Select-Object cmdlet.

Get-VM |

Select Name,NumCpu,MemoryMB,

    @{N='OS';E={$_.Guest.OSFullName}},

    @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

    @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}} |

Export-Csv report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Reply
0 Kudos
jessem
Enthusiast
Enthusiast
Jump to solution

This is great LucD!  Do you know what property I can add the VM folder in vCenter and ESXi host to this?

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

You can find all properties of the returned objects from Get-VM in the VirtualMachine object.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jessem
Enthusiast
Enthusiast
Jump to solution

I tried the script and it doesn't work.

Get-VM |

Select Name,NumCpu,MemoryMB,Folder,VMHost

    @{N='OS';E={$_.Guest.OSFullName}},

    @{N='Datacenter';E={Get-Datacenter -VM $_ | Select -ExpandProperty Name}},

    @{N='Cluster';E={Get-Cluster -VM $_ | Select -ExpandProperty Name}} |

Export-Csv report.csv -NoTypeInformation -UseCulture

When I run it from powercli, it outputs in the cmd box, name, cpu, memory, folder, host.  However, when I open up the csv file, I get this:

   

IsReadOnlyIsFixedSizeIsSynchronizedKeysValuesSyncRootCount
FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
FALSEFALSEFALSESystem.Collections.Hashtable+KeyCollectionSystem.Collections.Hashtable+ValueCollectionSystem.Object2
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I suspect you might have forgotten a comma after VMHost


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

jessem
Enthusiast
Enthusiast
Jump to solution

OMG, thanks.  You are a life saver.

Reply
0 Kudos