VMware Cloud Community
SureshDhanaraj
Contributor
Contributor
Jump to solution

PowerCLI script to validate all the hosts in vCenter Intel VT enabled or no

Hi,

I have a vCenter which has around 50 -60 ESXi 5.0 host. Which was newly installed which has Intel processor. I just want to ensure all the hosts Intel VT enabled or not. If anyone has the PowerCLI script to validate this please share it with us. Thanks in advance.

Regards

Suresh Dhanaraj

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Can't you just do

$esxcli = Get-EsxCli -VMHost "esx1.local.test" 
$esxcli.hardware.cpu.global.get()

and check the value of the HVSupport property ?


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

View solution in original post

0 Kudos
7 Replies
SG1234
Enthusiast
Enthusiast
Jump to solution

really good question - can you do a cat /proc/cpuinfo from the  ESXi shell?

0 Kudos
JorgeBuitrago
Contributor
Contributor
Jump to solution

You could use esxcfg-info command as described in the following kb :http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=101171...

To script this for a large environment, you can use plink in combination with the cmdlet Invoke-Expression:

$plink = "plink.exe"
$plinkoptions = " -v -batch -pw $Password"
$remoteCommand = '"' + $Command + '"'
$PlinkCommand = $plink + " " + $plinkoptions + " " + $User + "@" + $VMHost + " " + $remoteCommand
$Output = Invoke-Expression -command $PlinkCommand
0 Kudos
SureshDhanaraj
Contributor
Contributor
Jump to solution

Hi,

Thanks. I already have this script and placed the plink.exe at the execution path. It’s ruing w/o any error but it says the table title as “output” but no output data available. Please suggest.

Sample Output from PowerCLI:

---------------------------------------------------------

Host                  Output

----                      ------

test09.corp.com

test10.corp.com

test11.corp.com

test12.corp.com

test13.corp.com

test14.corp.com

test15.corp.com

test16.corp.com

Script:

-----------------------

$User = "root"
$Password = "Mypassowrd"
$Command = "esxcfg-info | grep 'HV Support'"
function Invoke-VMhostCommand {
  # This function assumes that plink.exe is in your path
  param([parameter(Mandatory=$true)][string] $VMHost,
        [parameter(Mandatory=$true)][string] $User,
        [parameter(Mandatory=$true)][string] $Password,
        [parameter(Mandatory=$true)][string] $Command)
  $plink = "C:\plink.exe"
  $plinkoptions = " -v -batch -pw $Password"
  $remoteCommand = '"' + $Command + '"'
  $PlinkCommand = $plink + " " + $plinkoptions + " " + $User + "@" + $VMHost + " " + $remoteCommand
  $msg = Invoke-Expression -command $PlinkCommand
  $Report = "" | Select-Object Host,Output
  $Report.Host = $VMHost
  $Report.Output = $msg
  $Report
}
$Report = Get-VMHost | ForEach-Object {Invoke-VMHostCommand -VMHost $_.Name -User $User -Password $Password -Command $Command }
$Report | Format-Table -AutoSize
Regards,
Suresh
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Can't you just do

$esxcli = Get-EsxCli -VMHost "esx1.local.test" 
$esxcli.hardware.cpu.global.get()

and check the value of the HVSupport property ?


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

0 Kudos
SureshDhanaraj
Contributor
Contributor
Jump to solution

Hi LucD & Team,

Thanks a lot for the reply. It’s really awesome it works perfect. After going through VMworld 2011 PowerCLI videos I became fan of you & Alan. Thanks a lot for sharing valuable information.

Regards

Suresh Dhanaraj

0 Kudos
RichardJohnsonR
Contributor
Contributor
Jump to solution

LucD,

1st of all, thanks for the 2 liner.

2nd, quick Q for you.  Is there a way of exporting the HVSupport attribute into a CSV e.g. @{N="VT Support";E={$_. ..........}}, ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Sure, by using the info from KB1011712 you can even use a meaningful text instead of the number.

Something like this

$HVinfo = "VT/AMD-V indicates that support is not available for this hardware.",
 
"VT/AMD-V indicates that VT or AMD-V might be available but it is not supported for this hardware.",
 
"VT/AMD-V indicates that VT or AMD-V is available but is currently not enabled in the BIOS.",
 
"VT/AMD-V indicates that VT or AMD-V is enabled in the BIOS and can be used."

Get-VMHost | Select Name,
 
@{N="HVSupport";E={
   
$esxcli = Get-EsxCli -VMHost $_
   
$index = $esxcli.hardware.cpu.global.get() | Select -ExpandProperty HVSupport
   
$HVinfo[$index]
  }}
|
Export-Csv C:\HV-report.csv -NoTypeInformation -UseCulture

Note that this will only work for ESXi 5.* hosts this way.

With ESXi 4.* hosts you will have to do a Connect-VIServer to each one before doing the Get-EsxCli.


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

0 Kudos