Not the Error I expected! Connect-NsxtServer

Howdy!

It’s been quite a while since I created a blog post. Not sure I would want to say exactly how long. However, today I had a brand new VM that I was using to write some automation with PowerShell/PowerCLI. It took me a few minutes to figure this one out. Maybe it was me?

As I said I set up a brand new machine, updated .net, connected to our internal PowerShell Gallery and installed the latest version of VMware.PowerCLI ~ version 13. The automation I wanted to perform was specifically related to getting some health and status of different pieces of NSX. I ran the following command :

Connect-NsxtServer -Server nsxmgr.local -user admin -password "VMware1!"

The error is below:

Connect-NsxtServer : 13/02/2025 13:15:09 Connect-NsxtServer Unable to connect to the remote server
At line:1 char:1
+ Connect-NsxtServer -Server nsxmgr.local -User admin -Password .......

“Unable to connect to the remote server” – Now being the seasoned system administrator I am, I immediately thought to myself. “ITS DNS!” I was so proud of myself. Finally identified that DNS issue before anyone else! So I opened up a separate cmd window – because for some reason I hate to ping from PowerShell consoles.

Imagine my shock when I was able to ping and resolve the name of the NSX server with no issue. I was so disappointed, disappointed it wasn’t working, disappointed it wasn’t DNS. So I went back to my primary development machine – had no issues connecting to the NSX server. I probably spent more time than I needed troubleshooting the network of this new virtual machine. I checked the MAC address, made sure I could ping the gateway. The error made no sense to me.

Next logical step for me was to connect to a vCenter – that always works.

Connect-VIServer 192.168.0.10 -user administrator -password "VMware1!"

Boom! Oh wait…. An error? What is wrong with me today?

Connect-VIServer : 13/02/2020 13:21:46  Connect-VIServer                Error: Invalid server certificate. Use Set-PowerCLIConfiguration to set the value for the InvalidCertificateAction option to Prompt if you'd like to connect once or to add a permanent exception for this server.
Additional Information: Could not establish secure channel for SSL/TLS with authority .....

This is an error I have seen many times before. For some reason I did not think to set the PowerCLI configuration on this new machine, knowing I was only going to be connecting to NSX. I ran the following command:

Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -ParticipateInCeip $false

Now I was able to run the command to connect to the NSX server.

Connect-NsxtServer -Server nsxmgr.local -user admin -password "VMware1!"

I was back in business and quickly completed the deployment of my scripts to check on those health and well being of our NSX items.

The reason this caught me off guard was that with the same “Verb” and essentially the same module – I got different errors for the same underlying issue.

Hopefully someone reads this and finds it useful. It is not by any means a new issue. Just a fun little problem I ran across taking things for granted.