Skip to main content

Posts

Showing posts from November, 2014

Reconnecting ESXi servers with PowerCLI

We recently needed to re-ip our vCenter servers; each with ~200 ESXi servers which needed to be reconnected - thank goodness for PowerCLI.  Since there isn't a "Reconnect-VMHost" cmdlet provided by PowerCLI we needed to check the HostSystem Object at h ttps://www.vmware.com/support/developer/converter-sdk/conv55_apireference/vim.HostSystem.html and to see what methods were available (hint: there's a ReconnectHost_Task method which will do the trick).  We can still leverage the "Get-VMHost" cmdlet to return the disconnected ESXi servers and then call the ReconnectHost_Task method to reconnect each ESXi server.  The code is fairly short: Get-VMHost -state Disconnected | foreach-object {   $vmhost = $_   $connectSpec = New-Object VMware.Vim.HostConnectSpec   $connectSpec.force = $true   $connectSpec.hostName =  $vmhost .name   $connectSpec.userName = 'root'   $connectSpec.password = 'MySecretPassword'    $vmhost .extensionData.Reconnec