"Object reference not set to an instance of an object" error while reconnecting Connect-VIServer PowerCLI command post ESXi host reboot
search cancel

"Object reference not set to an instance of an object" error while reconnecting Connect-VIServer PowerCLI command post ESXi host reboot

book

Article ID: 345498

calendar_today

Updated On:

Products

VMware vCenter Server VMware vSphere ESXi

Issue/Introduction

Symptoms:
  • Customer can connect to PowerCLI using Connect-VIServer command for the first time, however post ESXi host reboot the PowerCLI when customer tries to use Connect-VIServer command gets an error "Object reference not set to an instance of an object".
  • This is observed in PowerCLI version 13.1.0.


Environment

VMware vSphere PowerCLI 13.1
VMware vSphere ESXi 7.0
VMware vCenter Server 7.0.x

Resolution

VMware is aware about this issue and currently there is no resolution. This is expected to be fixed in the future release.


Workaround:

Workaround 1: 

Close and Reopen PowerCLI session.

 

Workaround 2:

When PowerCLI is connected using FQDN post ESXi host reboot, customer should reconnect to host via IP address and vice-versa.

  • Connect-VIServer ESXiHostname -User root -Password 'xxxxxxxx' # Connect and work as usual
  • Get-VM
  • Get-VMHost | Restart-VMHost -Force # Reboot the ESX server you're connected to
  • Disconnect-VIServer ESXiHostname # Disconnect right after initiating the server reboot
  • Start-Sleep (60 * 5) # Wait 5 minutes for the server to boot up - you may want to tweak this interval or implement polling
  • Connect-VIServer ESXiHostname -User root -Password 'xxxxxxxx' # Connect again and continue working as usual
  • Get-VM