Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

VMware PowerCLI Connect-VIServer Object reference not set to an instance of an object

While connecting to ESXi server with VMware PowerCLI from one of my server I was keep receiving below error. I wasn't able to connect to ESXi server directly from PowerCLI module. 

@SERVER01 ~ Connect-VIServer ironman.vcloud-lab.com
Connect-VIServer :  Object reference not set to an instance of an object.
At line:1 char:1
+ Connect-VIServer ironman.vcloud-lab.com
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo           : NotSpecified: (:) [Connect-VIServer], NullReferenceException
    + FullyQualifiedErrorId  : System.NullReferenceException,VMware.VimAutomation.ViCore.Cmdlets.Commands.ConnectVIServer

Microsoft PowerShell vmware vsphere vcenter esxi PowerCLI vcsa vcenter server appliance connect-viserver virtualization automation protocol object reference not set.png

Another related article: VMware PowerCLI esxcli namespace command elements empty no output

After trying few troubleshooting options I came to know, this issue occurs due to old version of the VMware PowerCLI I was using, possibly due to bugs in older version, I went to the Powershell Gallary (psgallery) website and checked the latest version. I found I was running way back older version of PowerCLI.

https://www.powershellgallery.com/packages/VMware.PowerCLI/

VMware.PowerCLI vmware vsphere vCenter server esxi vcsa Microsoft Powershell gallery modules package azure automation psgallery nuget automation get-vmhost.png

From commands, I can check the current version of installed VMware.PowerCLI module. Next I can find latest PowerCLI module available online. Module can be easily updated with Update-Module.

@SERVER01 ~ Get-PowerCLIVersion
@SERVER01 ~ Find-Module VMware.PowerCLI
@SERVER01 ~ Update-Module VMware.PowerCLI -Scope CurrentUser

Microsoft Powershell vmware vsphere vcenter server vcsa esxi Get-PowerCLIVersion cis core vimautomation update module scope currentuser vmware.powercli untrusted repository set-psrepository psgallary.png

Once Module is downloaded and uploaded locally successfully from PSGallery repository, Checked the command again to verify the PowerCLI version. Alternatively to check latest version Get-Module -List command can also be used. In the last verify if I am able to connect to ESXi server.

@SERVER01 ~ Get-PowerCLIVersion
@SERVER01 ~ Connect-VIServer ironman.vcloud-lab.com

vmware vsphere vCenter esxi vcsa vcenter server appliance microsoft powershell module powercli version Get-PowerCLiVersion Connect-Viserver certificate is not valid error vimautomation.core.png

Useful Articles
Resolved: HP ILO this page cannot be displayed ERR_SSL_BAD_RECORD_MAC_ALERT
Reset/Restart HP ILO (Integrated Lights-outs) using putty
Reset HP ILO password from Esxi server
ESXi HP Blade start issue Enclosure power event detected, System Halted until power condition is corrected
Esxi update individual component firmware on HP hardware: disk degraded not authenticated
Resolved syslog error: Call OptionManager.UpdateValues for object ha-adv-options on ESXi failed
Solved: Esxi server cannot joined into active directory domain
Solved Esxi host disconnected evaluation license expired
Connect-VIServer Error: Invalid server certificate. Use Set-PowerCLIConfiguration

Go Back



Comment

Blog Search

Page Views

5937698

Follow me on Blogarama