Automation

 View Only
Expand all | Collapse all

How to check if VT is enabled

  • 1.  How to check if VT is enabled

    Posted Aug 26, 2010 01:48 AM

    Hi There,

    We have a large VM enviromnent and I want to be able to check if Intel VT is enabled using a powershell script for enitre ESX servers (Dell Poweredge) via VC, hoping someone wrote a script that can do this task in a single execution.

    Thanks in Advance.

    If you found this information useful, please consider awarding points for Correct or Helpful.



  • 2.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 07:53 AM

    You can use the console command 'esxcfg-info|grep "HV Support"' and plink.exe to get the VT enabled status from PowerCLI. See for an example of using plink.exe. You can download plink.exe from the PuTTY Download Page if you don't have it already.

    Information about the output of the HV Support command can be found in the VMware Knowledge base article Determining if Intel Virtualization Technology or AMD Virtualization is enabled in the BIOS without rebooting.

    Combining all these information I come to the following script:

    $User = "root"
    $Password = "password"
    $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 = "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, Robert

    Message was edited by: RvdNieuwendijk



  • 3.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 10:27 AM

    Wow, this is such a good article.

    Kind Regards,

    AWT



  • 4.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 06:02 PM

    Hi Albert,

    I'm glad you like it.

    Regards, Robert



  • 5.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 03:57 PM

    Can any one tell me how to run this script? I have downloaded and kept the plink.exe on my c:\windows path. I also have power path installed.

    thanks



  • 6.  RE: How to check if VT is enabled

    Posted Oct 07, 2010 06:58 AM

    Hi Tom,

    From where did you downloaded the plink.exe ?



  • 7.  RE: How to check if VT is enabled

    Posted Oct 07, 2010 07:04 AM

    The PuTTY Suite download page.

    ____________

    Blog: LucD notes

    Twitter: lucd22



  • 8.  RE: How to check if VT is enabled

    Posted Oct 08, 2010 05:23 AM

    Ah... thanks man, I really appreciate your help.

    Cheers,

    Albert



  • 9.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 06:21 PM

    If you make a mistake in a post you can use the edit link to change it. So you don't have to make a new post to correct it. I use it all the time. :smileywink:

    To use the script you need PowerShell v2 and VMware vSphere PowerCLI, which you can download from http://www.vmware.com/go/powercli.

    Before you run the script you need to connect to a vCenter server first with the Connect-VIserver cmdlet. If your vCenter server is called vCenter1 you can do this with:

    Connect-VIserver vCenter1 -Credential (Get-Credential)
    



  • 10.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 06:27 PM

    Actually, I tried stopping the request via browser and I thought it did not go through :smileyhappy: But after wards, I saw I have 2 posts now. :smileyhappy:

    This is the erro message I am getting

    PS C:\Documents and Settings\tom\Desktop> .\vt.ps1

    Parameter attributes need to be a constant or a script block.

    At C:\Documents and Settings\tom\Desktop\vt.ps1:7 char:35

    + param([string] $VMHost,

    PS C:\Documents and Settings\tom\Desktop>

    Thanks



  • 11.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 06:30 PM

    I deleted the duplicate post for you :smileywink:



  • 12.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 06:47 PM

    It looks like you are running PowerShell v1. The script uses features that are new in PowerShell v2. So you need to install that to run this script. You can check if you are running PowerShell v2 with the $host.version command. It should return:

    [vSphere PowerCLI] C:\users\robert> $host.version
    
    Major  Minor  Build  Revision
    -----  -----  -----  --------
    2      0      -1     -1
    

    You can download PowerShell v2 from Download Windows PowerShell.



  • 13.  RE: How to check if VT is enabled
    Best Answer

    Posted Aug 26, 2010 07:02 PM

    This is what it returns

    PS C:\Documents and Settings\tom\Desktop> $host.version

    Major Minor Build Revision

    -


    -


    -


    -


    2 0 -1 -1



  • 14.  RE: How to check if VT is enabled

    Posted Aug 26, 2010 08:51 PM

    It looks like you have PowerShell v2 allready installed. Maybe something is wrong with the installation. Can you try to remove PowerShell from your system and install PowerShell v2 again?