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

10 thoughts on “VI Toolkit One Liner: Correct HAL ?

  1. Pingback: PowerCLI: More HAL Information « Virtu-Al

  2. Nathan Hammes

    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.

  3. Virtu-Al

    @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.

  4. nikes

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

  5. Virtu-Al

    @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 🙂

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.