Skip to content

NKCODE TECH GEEK ZONE

  • RSS - Posts
Menu
  • Home
  • Cloud
    • Azure
    • Alibaba
    • AWS
  • Hardware
  • Linux
  • Network
  • Security
  • Windows Client / Servers
    • SQL
    • Windows Client OS
      • Windows 10
    • Windows Servers
      • Windows 2008R2
      • Windows Server 2012R2
      • Windows Server 2016
      • Windows Server 2019
  • VMWARE
  • Free Tools
  • About Me
    • Disclaimer
Menu

ESXi root password is Loss and Create New Admin Account

Posted on May 7, 2022

Log in with administrator access to vCenter, so instead of changing the root password thru PowerCLI.

PowerCLI to create an additional admin on the host for the troubleshooting, using this script:

#connect to the vCenter
connect-viserver <vCenter FQDN>

#get the ESXi host
$vmhost = get-vmhost -name <ESXi host FQDN>

#connect to the "esxcli" command environmant
$esxcli = Get-EsxCli -VMHost $vmhost -v2

#create temp user
$arguments = $esxcli.system.account.add.CreateArgs()
$arguments.id = 'tempuser'
$arguments.password = 'TempPass1!'
$arguments.passwordconfirmation = 'TempPass1!'
$esxcli.system.account.add.Invoke($arguments)

#Set tempuser to Admin
$arguments = $esxcli.system.permission.set.CreateArgs()
$arguments.id = 'tempuser'
$arguments.role = "Admin"
$esxcli.system.permission.set.Invoke($arguments)

NOTE: Please understand what the script is doing, you are using this script at your own risk, so please test it before using it.

After this, I could connect to the ESXi host, and do the troubleshooting, and after finishing this, I deleted the user again, since I used the wrong password for this, and not leaving a user on the host that the service provider is not aware of.

NOTE: It’s a good idea to remove the user afterwards again, this can also be done thru PowerCLI


#connect to the vCenter
connect-viserver
#get the ESXi host
$vmhost = get-vmhost -name
#connect to the "esxcli" command environmant
$esxcli = Get-EsxCli -VMHost $vmhost -v2
#remove tempuser
$arguments = $esxcli.system.account.remove.CreateArgs()
$arguments.id = 'tempuser'
$esxcli.system.account.remove.Invoke($arguments)

Share this:

  • Click to share on X (Opens in new window) X
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to email a link to a friend (Opens in new window) Email

Like this:

Like Loading...

Related

Welcome to Teck Geek Zone

Alibaba & Azure Cloud with a free trial worth $200-1200 USD Click below Cloud Providers

  • Securing Your Cloud Environment with Alibaba Cloud Firewall
  • 🚢 Sailing into the Data Age: How Cloud and IoT are Revolutionizing the Marine Industry
  • What is Azure Grafana? A Comprehensive Guide to Monitoring and Visualization
  • 🔐 How to Enable Virtualization-Based Security (VBS) for Windows Workloads in VMware Cloud Foundation and vSphere
  • Microsoft’s Azure SRE Agent: AI-Powered Reliability Engineering

Categories

  • Cloud (186)
    • Alibaba (39)
    • AWS (39)
    • Azure (114)
  • Free Tools (5)
  • Hardware (17)
  • Linux (13)
  • Network (28)
  • Security (21)
  • VMWARE (54)
  • Windows OS (44)
    • Windows 10 (7)
  • Windows Servers (69)
    • SQL (3)
    • Windows 2008R2 (7)
    • Windows Server 2012R2 (15)
    • Windows Server 2016 (20)
    • Windows Server 2019 (10)

Subscribe to our newsletter

©2025 NKCODE TECH GEEK ZONE | Design: Newspaperly WordPress Theme
%d