When I began working with a new client on their Virtualization Broadcom VMware project, I encountered several ESXi servers that were already deployed and connected to vCenter servers. Since I was new to the project, I found that the root passwords for some of these ESXi servers were undocumented and unknown.
In certain cases, I needed the root password to log in and retrieve low-level information from these servers. Fortunately, if an ESXi server is connected to vCenter, it's possible to reset the root password using VMware PowerCLI, which allowed me to address the issue without direct access to the initial credentials.
Here’s a streamlined description of the script steps for resetting an ESXi root password via PowerCLI:
- Import the PowerCLI Module: Begin by importing the
VMware.PowerCLI
module in PowerShell. - Connect to vCenter: Establish a connection to the vCenter server by logging in with the appropriate credentials.
- Specify ESXi Host Details: Identify the ESXi host for which you need to reset the password. Typically, you will use the host name as it appears in vCenter. Specify the username (usually "root") and the new password.
- Retrieve ESXi Information and Establish Connection: Use
Get-VMHost
to get ESXi host information, then create anEsxCli
object usingGet-EsxCLI
to interact with the host. - Reset the Password: With the
esxcli system account
command, you can list and set the new password for the root account. - Verify Success: After successfully setting the password, a confirmation message (
true
) will appear, indicating the password reset was successful.
This process provides an efficient way to reset an ESXi root password for servers connected to vCenter, without needing prior knowledge of the current password.
$vcenter = 'vcenter_ip_fqdn' $vcenterUser = '[email protected]' $vcenterPassword = 'P@55w0rd' Import-Module VMware.VimAutomation.Core Connect-Viserver -Server $vCenter -User $vcenterUser -Password $vcenterPassword ############################################################### $esxiName = 'esxi_name_from_vCenter' $esxiUserName = 'root' $esxiNewPassword = 'P@55w0rd' $esxi = Get-VMHost | Where-Object { $_.Name -eq $esxiName } $esxcli = $esxi | Get-EsxCLI -V2 $rootUser = $esxcli.system.account.list.Invoke() | Where-Object { $_.UserID -eq $esxiUserName } $userArg = $esxcli.system.account.set.CreateArgs() $userArg.id = $rootUser.UserID $userArg.password = $esxiNewPassword $userArg.passwordconfirmation = $esxiNewPassword $esxcli.system.account.set.Invoke($userArg)
Useful Articles
Reset forgotten ESXi root password on Domain joined Esxi using vSphere web client and Powercli
Reset ESXi root password using Host Profiles on vCenter server: VMWare vSphere Web client
Resolved: Reset Esxi forgotten root password using hiren bootCD step by step
PART 1 : INSTALLING ESXI ON VMWARE WORKSTATION HOME LAB
PART 2 : CONFIGURING ESXI ON VMWARE WORKSTATION HOME LAB
PART 3 : ACCESSING STANDALONE ESXI SERVER IN HOME LAB USING VSPHERE CLIENT
Create bootable USB from ISO file
Adding and sharing RDM disk to multiple VMs in VMware step by step
Upload files to vmware ESXi datastore: Different methods
How to convert RDM disk (Raw Device Mapping) to VMDK
Find Dell iDrac, HPE ilo IPMI ip address on VMware ESXi
Reset Dell iDRAC password from ESXi server
Install Update VIB Zip files software on VMware ESXi server
Uninstall Remove VIB software from ESXi server