VMware VMware vSphere Blog
  • VMware Blogs
  • Communities
  • RSS Feed
  • Twitter
  • YouTube
  • Facebook
  • Categories
    • Architecture
    • Product Announcements
    • Technical
  • Learning
    • vSphere Tech Zone
    • Hands-on Labs
    • Read Whitepapers
  • Breakroom Chats
  • RSS Feed
  • Twitter
  • YouTube
  • Facebook
Product Announcements

Winner of Cycle 8 on ESXi

Michael Adams
January 29, 2010
Share on:
  • Share on Twitter
  • Share on LinkedIn
  • Share on Facebook
  • Email this post

Congratulations to Alan Renouf and his post on ESXi entitled "PowerCLI: Scripting ESXi". Alan's entire post can be seen below and also at http://www.virtu-al.net/2010/01/15/powercli-scripting-esxi/

PowerCLI: Scripting ESXi

As the service console is moved further away from the hypervisor, people are finding it harder to configure ESX in the same way as has been done in previous versions.

Moving forward the only way to do this really is by accessing ESXi through the API using scripting toolkits such as PowerCLI or the Perl toolkit.

There are two basic versions of ESXi “free” and “licensed”, the scripting toolkits are limited to read-only access for the free version of VMware ESXi. When the host is upgraded to vSphere Essentials, vSphere Essential Plus, vSphere Standard, vSphere Advanced, vSphere Enterprise, or vSphere Enterprise Plus these toolkits have write-access enabled and provide a scriptable method for managing ESXi hosts.

So what can we do ?  I have collated some useful ESXi methods into this blog post to help you when looking towards the future and trying to automate your configuration and management process of your ESXi hosts, all of the PowerCLI cmdlets will work in exactly the same way they would do with ESX but the below are a subset of useful functions and scripts which are either unique to ESXi or enable the easier management of ESXi.

The initial build of ESXi has no password so lets start there, how do we connect to the host ?

We connect in the normal way but we specify a username of root and no password as follows:

1 Connect-VIServer MyESXiHost -username root

Once connected we may want to change the password to something more secure, when doing this remember ESXi has a stricter password policy so make sure you have a password full of special characters, for more information on the default password rules and how to change these make sure you check out this link.

1 Set-VMHostAccount -UserAccount root -password MyPa$$!

We can view the hostd, messages and vpxa log files of the host by using one of the following:

1 Get-Log hostd | select -ExpandProperty Entries

1 Get-Log messages | select -ExpandProperty Entries

1 Get-Log vpxa | select -ExpandProperty Entries

Or search for a particular string in these files by using the following:

1 Get-Log hostd | select -ExpandProperty Entries | Select-String WARNING

Or we could create a diagnostic bundle by using:

1 Get-Log -Bundle -DestinationPath C:Temp

What about some of the cooler functions like Lockdown Mode or sometimes known as Admin mode ?

When connected to a vCenter we can list the ESXi hosts to see if this feature is enabled by using:

1 Get-View -ViewType HostSystem | Select Name, @{N="Version";E={$_.Summary.Config.Product.Name}}, @{N="State";E={$_.Runtime.ConnectionState}}, @{N="LockedMode";E={$_.Config.AdminDisabled}},@{N="MaintenanceMode";E={$_.Runtime.InMaintenanceMode}} | Where { $_.Version -match "i"}

With the help of the excellent function in the ‘VI Toolkt Extensions’ (get them now!) we can even enable and disable lockdown mode:

1 Get-VMHost | Set-TkeVMHostLockdown $True

Or to disable

1 Get-VMHost | Set-TkeVMHostLockdown $False

We can backup the firmware or configuration so that we can easily restore it again after all our hard work:

1 Get-VMHost MyESXiHost | Set-VMHostFirmware -BackupConfiguration -DestinationPath C:Temp

Once downloaded don’t forget you can always extract the files, edit them, re-compress and upload them back to the host !

(see this video from Eric Sloof)

And with the help of another cool function in the VITKE we can upload the firmware file and apply it:

1 $ESXiHost = Get-VMHost MyESXiHost

2 If ($ESXiHost.MaintenanceMode -eq $false) {

3    Set-VMHost $ESXiHost.Name -State maintenance }

4    Set-TKEVMHostFirmware -vmhost $ESXiHost –localfile “C:tempbackup.tgz” -credential (get-credential)

If you like you can also set the firmware back to default and get rid of all the changes you have made to the host:

1 Get-VMHost MyESXiHost | Set-VMHostFirmware -ResetToDefaults

These are but a few of the cmdlets we can use against our ESXi host, do you really need a better reason to start learning PowerCLI ?!

A reminder that some of these actions are also available via my VESI/PowerGUI PowerPack, these can be activated from the GUI when selecting the “ESXi Hosts” node and are available on the right hand side of the screen under “ESXi Utils” as seen below:

image

Related Posts:

  • Photon OS Logo
    Announcing Photon OS 5.0 - General Availability
  • #vSphereCheer Sneaker Giveaway
    #vSphereCheer LinkedIn Giveaway – How do our vSphere…
  • 2021-vSphere-Family-Icon-576×324
    vSphere 8 Achieves General Availability
  • VMware vSphere+
    Cloud Consumption Interface for vSphere+ Now…
  • 2022-vSphere-Icon
    What's New in vSphere Automation: PowerCLI
  • 2022-vSphere-Icon
    What's New in vSphere Automation: Power Actions
  • VMware vSphere+
    Announcing Early Availability of VMware ESXi…
  • Engineer using laptop computer for maintenance automatic robotic arm with CNC machine in smart factory. Industry 4.0 concept
    Learn From an Industry Professional and Solve Your…
  • CCI1
    Announcing the Initial Availability of VMware Cloud…
  • vSphere 8 Update 2
    Announcing vSphere Q3 2023 Release
  • vSphere+ Logo Official
    Introducing VMware vSphere+ Standard edition
  • 2021-vSphere-Family-Icon-576×324
    VMware vSphere will support the latest 4th…
  • 2021-vSphere-Family-Icon-576×324
    Introducing vSphere 8 Update 1
  • 2022-vSphere-Plus-Icon
    What's New in vSphere Automation: vSphere APIs,…

Michael Adams

Related Articles

Increase value, growth value, company value added or business growth concept. Businessman show circle  bar info graphic technology background. Sale digital marketing leadership success target
Product Announcements

VMware vSphere Foundation: Optimizing Private Clouds and Driving IT Value

Himanshu Singh
April 10, 2024
Product Announcements

Embracing Change with VMware vSphere Foundation

Himanshu Singh
January 17, 2024
Product Announcements

Announcing New Collaborations in VMware Private AI

Krish Prasad
November 7, 2023