Skip to main content

Changing ESXi root passwords the smart way (via PowerCLI)

 Author
Author
Sam McGeown
Steely-eyed missile man
Warning: This article is now 13 years old! It is highly likely that this information is out of date and the author will have completely forgotten about it. Please take care when following any guidance to ensure you have up-to-date recommendations.

PowerCLI LogoIf you work in company with strict password compliance rules, for example under SOX, you might well have to change administrator passwords every month. Doing this on any more than a few hosts is tedious work – even on two hosts it seems like a waste of time logging on the host via SSH (or even enabling it first) before changing the password. Then we also need to audit the change, there’s no point making it for compliance reasons if we can’t then prove we did it!

Changing ESXi passwords the manual way
#

Steps taken from VM KB 1004659

  1. Log on to SSH as root, or log on and use “su –“ to get root level access
  2. Use “passwd root” to change the root password
  3. Log off and log back on using the new password to test access

Rinse and repeat

Changing ESXi root passwords the smart way (via PowerCLI)
#

The script is fairly heavily commented, usage is as follows:

.\Change-HostPasswords.ps1 -vCenter VC-01.definit.local -Location “DefinIT Lab”

Source code for this has moved to GitHub to allow a bit more structured collaboration:

https://github.com/sammcgeown/Change-HostPasswords/blob/master/Change-HostPasswords.ps1