VMware Cloud Community
vmk2014
Expert
Expert
Jump to solution

Validating Bulk ESXi root password

Hi All,

I'm trying to validate the bulk ESXi password, but it fails with an error Log write function. Any help will be appreciated. It appears SSH  services need to be started prior to running the script.

after enabling the ssh services there is no error using Write-host function as per my understanding.

pastedImage_12.png

$esxNames = Get-Content -Path 'C:\tmp\list.txt'

$user = 'root'

$pswds = 'pswd1', 'pswd2', 'pswd3'

foreach ($esx in $esxNames)

{

   $i = 1

   foreach ($pswd in $pswds)

   {

   try

   {

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

  LogWrite "Host $esx password$i is correct"

   Disconnect-VIServer -Server $esx -Confirm:$false

   break

   }

   catch

   {

  LogWrite "Host $esx password$i failed"

   }

   $i++

   }

}

Thanks

V

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

The original thread where the base of that script is coming from, contained a function LogWrite.
You will have to include it if you want to use it.

Function LogWrite {

    Param ([string]$logstring)


    Add-Content $Logfile -value $logstring

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

0 Kudos
1 Reply
LucD
Leadership
Leadership
Jump to solution

The original thread where the base of that script is coming from, contained a function LogWrite.
You will have to include it if you want to use it.

Function LogWrite {

    Param ([string]$logstring)


    Add-Content $Logfile -value $logstring

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos