Connecting and disconnecting servers

Before you can do useful things with PowerCLI, you have to connect to a vCenter Server or an ESXi server. And if you are finished, it is a good practice to disconnect your session. We will discuss how to do this in the following sections Connecting to a server, Connecting to multiple servers, Suppressing certificate warnings , and Disconnecting from a server.

Connecting to a server

If you are not connected to a vCenter or an ESXi server, you will get an error message if you try to run a PowerCLI cmdlet. Let's try to retrieve a list of all of your data centers using the following command:

PowerCLI C:\> Get-Datacenter

The output of the preceding command is as follows:

Get-Datacenter : 1/7/2017 1:37:17 PM Get-Datacenter ...

Get Learning PowerCLI - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.