Automation

 View Only
  • 1.  How to check ESXi root password for all VMhost in the VCenter ?

    Posted Sep 06, 2013 10:51 AM

    hi,

    Can anyone please share he way or any script to check the VMware root credentials ?

    rather than trying to login to each VMhost ESX(i) with vsphere client is too much of a work 



  • 2.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Sep 06, 2013 11:35 AM

    Try something like this

    $user = "root"
    $pswd = "lala"
    foreach($esx in Get-VMHost){
       
    try {
           
    Connect-VIServer -Server $esx -User $user -Password $pswd -ErrorAction Stop | Out-Null
        }
       
    catch{
           
    "Logon failed on $($esx.Name)"
        }
    }


  • 3.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Sep 07, 2013 01:39 AM

    Thanks for the reply Luc,

    However if it is just one line connect to the ESX host it works, somehow it doesn't work in the loop ?

    Initially I have logged on to the VCenter server and then execute the script that you created but it is all returning failed, the credentials has always been right when I check manually.



  • 4.  RE: How to check ESXi root password for all VMhost in the VCenter ?
    Best Answer

    Posted Sep 07, 2013 02:26 AM

    The reason the script that LucD provided isn't working is because you need to change $_ to $esx (shown below). You use the $_ when your piping output from one command to another. Since we're using we're using a Foreach loop we access the individual items of the Get-VMHost command through the defined variable (the $esx in the 3rd line)

    Connect-VIServer -Server $esx -User $user -Password $pswd -ErrorAction Stop | Out-Null



  • 5.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Sep 07, 2013 04:40 AM

    thanks man it works now :-)



  • 6.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Sep 07, 2013 08:21 AM

    I corrected the code



  • 7.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted May 28, 2020 05:45 AM

    Our ESXi hosts recently got locked out. Is there any powercli to know the current status of ROOT account if its locked or failed logon attempts.



  • 8.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted May 28, 2020 06:23 AM

    You can query the events (provided you keep them for sufficiently long).

    The event should say when it happened and for how long the account will be locked.

    $esxName = 'MyEsx'

    Get-VIEvent -Entity $esx -Start (Get-Date).AddMinutes(-15) -MaxSamples ([int]::MaxValue) |

    where{$_ -is [VMware.Vim.EventEx] -and $_.EventTypeId -eq 'esx.audit.account.locked'}



  • 9.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Jul 01, 2020 07:58 AM

    LucD,

    If i want to validate the root password for 140 standalone hosts, then in that case the below script will work ?

    Thanks

    V



  • 10.  RE: How to check ESXi root password for all VMhost in the VCenter ?

    Posted Jul 01, 2020 08:04 AM

    You will need to have a list with the FQDN of the ESXi nodes and the root credentials to try.

    Then a Connect-VIServer to the ESXi node with those credentials in a try-catch construct should do the trick.

    It would be more like the script in Re: Validate ESXi root password against multiple passwords

    With the exception that you would only test against 1 root credential