PowerCLI

 View Only
  • 1.  Getting Host Hardware Information through PowerCLI

    Posted Jan 16, 2013 08:15 PM

    Hello there,

    I have a list of information I would like to get from some of our hosts.  I've tried pulling this through PowerGUI and the VMWare PowerPacks but I'm having an issue with the fact that it will only pull down the hardware information for one of the hosts (even though I have 40 hosts connected under the managed hosts tab).

    I obviously have a lot to learn in PowerCLI but I was hoping that someone could provide some direction on this.

    I have a list of hosts that I have to connect with a pre-defined account and I'd like to pull down the following information into a CSV or some sort of report:

    Hostname

    Manufacturer / Model

    Processor Type

    Number of CPU / Cores

    Speed of CPU

    CPU Used

    Total Memory

    Memory Used

    ESXi Version

    All of the above information is avalible in PowerGUI but as I said I can only pull it for one host at a time for some reason.

    If possible I'd love to be able to get a list of running VMs on each host at the same time.

    I'd love some guidance on this or maybe if anyone has a bit more experience with PowerGUI and could let me know why it will only fill in the information for whatever my top listed host is.

    I've found a few examples I think I could mash together but I con't figure out how to define a specific username/password and have it pull a list of hosts rather than one at a time.

    It'd be awesome if someone had a similar script built and would let me take a look at it.

    Thanks for any help you can lend.  I really appericiate this commnunity.  =)



  • 2.  RE: Getting Host Hardware Information through PowerCLI
    Best Answer

    Posted Jan 16, 2013 09:48 PM

    Once you get the hang of this, it becomes quite easy.

    In your case, you want to list all your ESXi hosts and some properties for each host.

    The basic idea is to use the Get-VMHost cmdlet.

    Like this it will return all the ESXi servers in the vCenter to which you connected.

    Get-VMHost

    On screen you will see a number of default properties. This is determined by a kind of format file, but leave that for now.

    The above cmdlet returns an object that has more properties. To see all the properties do a Get-Member

    Get-VMHost | Get-Member

    The next step is to select yourself which properties are to be displayed.

    For that you use the Select-Object cmdlet, something like this

    Get-VMHost | Select Name,Build,ConnectionState

    If you want to store the result in a file, you can use for example the Export-Csv cmdlet.

    Get-VMHost | Select Name,Build,ConnectionState | Export-Csv C:\report.csv -NoTypeInformation -UseCulture

    If you want to learn about parameters that can be used on a cmdlet, you can use the Get-Help cmdlet.

    For example

    Get-Help Export-Csv -Parameter NoTypeInformation

    will give help on that specific parameter. But you can also display the full help with

    Get-Help Export-Csv -Full

    That is in fact the basic concept behind reporting with PowerCLI/PowerShell;

    • get the objects
    • chose what you want to display
    • optionally save the result to a file

    Does this get you on your way to start ?



  • 3.  RE: Getting Host Hardware Information through PowerCLI

    Posted Jan 18, 2013 11:15 PM

    LucD:  I really appericiate that.  That was far above what I was looking for.  You explained it very well and I've built the script I need off of your examples and explantion.  I will definitly be working with PowerCLI more - this is a great tool.

    I was about to say you should write a book - but then I saw your sig. =)  Thanks again for your quick primer and help with this project.  I'll almost definitly be picking up your book.



  • 4.  RE: Getting Host Hardware Information through PowerCLI

    Posted Jan 19, 2013 12:49 AM

    Thanks, glad it helped you.



  • 5.  RE: Getting Host Hardware Information through PowerCLI

    Posted Jan 19, 2013 08:10 AM

    Use RVtool to get details



  • 6.  RE: Getting Host Hardware Information through PowerCLI

    Posted Jan 16, 2013 09:51 PM

    The following PowerCLI script retrieves the required information from all your hosts:

    Get-VMHost |
    Select-Object -Property Name,Manufacturer,Model,ProcessorType,
    @{Name="NumCpuPackages";Expression={$_.ExtensionData.hardware.CpuInfo.NumCpuPackages}},
    @{Name="NumCpuCores";Expression={$_.ExtensionData.hardware.CpuInfo.NumCpuCores}},
    CpuTotalMhz,CpuUsageMhz,MemoryTotalGB,MemoryUsageGB,Version |
    Export-Csv -Path VMHostInfo.csv -NoTypeInformation -UseCulture
    
    



  • 7.  RE: Getting Host Hardware Information through PowerCLI

    Posted Jan 18, 2013 11:17 PM

    Robert van den Nieuwendijk wrote:

    The following PowerCLI script retrieves the required information from all your hosts:

    Get-VMHost |
    Select-Object -Property Name,Manufacturer,Model,ProcessorType,
    @{Name="NumCpuPackages";Expression={$_.ExtensionData.hardware.CpuInfo.NumCpuPackages}},
    @{Name="NumCpuCores";Expression={$_.ExtensionData.hardware.CpuInfo.NumCpuCores}},
    CpuTotalMhz,CpuUsageMhz,MemoryTotalGB,MemoryUsageGB,Version |
    Export-Csv -Path VMHostInfo.csv -NoTypeInformation -UseCulture
    
    

    Thanks for the example script Robert.  I'll be working with it tonight.  Really appericiate it!