Virtu-Al.Net

Virtually everything is poshable

VI Toolkit One Liner: Correct HAL ?

I have just re-worked an old script which I created to check each VM to ensure they are using the correct HAL based on the amount of processors they have installed, as it turns out I managed to get this into a nice one-liner:

Get-VM | Where {$_.PowerState -eq "PoweredOn"} | Sort Name | Select Name, NumCPU, @{N="OS HAL";E={(Get-WmiObject -ComputerName $_.Name -Query "SELECT * FROM Win32_PnPEntity where ClassGuid = '{4D36E966-E325-11CE-BFC1-08002BE10318}'" | Select Name).Name}}

Or to break it down so it fits on my blog…

Get-VM | Where {$_.PowerState -eq "PoweredOn"} |
Sort Name |
Select Name, NumCPU, @{N="OS HAL";E={(Get-WmiObject -ComputerName $_.Name -Query 
"SELECT * FROM Win32_PnPEntity where ClassGuid = '{4D36E966-E325-11CE-BFC1-08002BE10318}'" |
Select Name).Name}}

Output:

hal

, ,

9 Responses to “VI Toolkit One Liner: Correct HAL ?”

  • Nice one Alan! This one I stored in my personal “RePOSHitory” :)

  • Marc says:

    Can you post how to output this to a csv?

  • Virtu-Al says:

    @Marc
    You can just pipe this into export-csv Filename, for example:

    | Export-csv c:\temp\HalList.csv

    Add that to the end of the one liner to make it an even longer one-liner and you should have your result :)

  • NiTRo says:

    Thanks Al, it’s a very useful script. And in one line, it’s really cool :)

  • nikes says:

    How can we check the service pack level of the VM’s running , we need to check it with the HAL list.

  • Virtu-Al says:

    @nikes
    You should be able to do this by using the following:

    Get-VM | Foreach { Get-WmiObject -ComputerName $_.Name -Class Win32_OperatingSystem | Select CSName, Caption, CSDVersion}

    You will obviously need permission to read the information from each guest system.

  • Nathan Hammes says:

    Hi Alan – quick question: I just ran this script for the first time and it is not pulling the HAL info for each guest VM. It pulls the # of vCPUs and the host name, but that is it. I run it with a domain admin acct, so it has local admin rights to every VM so I am not sure what I am missing. Any ideas? BTW – I have just started using PowerCLI and I really enjoy your site/scripts (and others you reference). Thank you so much – many of them have come in very handy. Very nice work.

  • Nathan Hammes says:

    I should mention I have a mix of 32 & 64 bit Windows guest VMs… Thanks again,

  • [...] following one-liner expands on my previous one-liner to include the following [...]

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>