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:
Could u pls explain, what is the purpose of having this script in xml form?
Pingback: PowerCLI: More HAL Information « Virtu-Al
I should mention I have a mix of 32 & 64 bit Windows guest VMs… Thanks again,
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.
@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.
How can we check the service pack level of the VM’s running , we need to check it with the HAL list.
Thanks Al, it’s a very useful script. And in one line, it’s really cool 🙂
@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 🙂
Can you post how to output this to a csv?
Nice one Alan! This one I stored in my personal “RePOSHitory” 🙂