List Connected vCenter Servers with PowerCLI

List Connected vCenter Servers with PowerCLI

This functionality is pretty slick and is done automatically when connecting to vCenter with PowerCLI. It’s an oldie but goodie and I wanted to toss this out there to help anyone.

When you use Connect-VIServer to connect to a system, two specific global variables are updated.

Either of these can be used to display the last vCenter server you connected to. Even if you’ve made multiple connections, the last one will be listed.

List Multiple Connected vCenters with PowerCLI

A slight variation to this is to make these plural:

If you have made connections to multiple vCenter servers, those systems will be displayed here! These are extremely helpful when working to simplify things. You can even pass session information by simply doing one of the following:

vCenter SessionID

You can pass this information into a Job (with Start-Job) and connect to the vCenter servers you’ve already established a connection to. 

Read the rest →