Change ESXi root password using esxcli through PowerShell

In my lab I discovered a host that had a root user password something else that I usually use. I was not able to figure it out. Since the host was connected to the vCenter  I used a PowerShell script to change it. NB! Make sure the new password meets the complexity requirements.

The script is following:

$esx_hosts = Get-VMHost my_host

foreach ($esx_host in $esx_hosts) {
  $esxcli = Get-EsxCli -VMhost $esx_host -V2
  $arguments = $esxcli.system.account.set.CreateArgs()
  $ = ‘root’
  $arguments.password = ‘Password123’
  $arguments.passwordconfirmation = ‘Password123’


This script can be used to change root or any other local user password on all ESXi hosts connected to vCenter.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.