O'Reilly logo

Mastering PowerCLI by Sajal Debnath

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding hosts to a vCenter server

To add a host to a vCenter server using the PowerCLI cmdlet, we need to use the Add-VMHost cmdlet. But, for this cmdlet to run successfully, we need to first connect to a vCenter server. We can connect to a vCenter server using the Connect-VIServer cmdlet. So, let's start:

PS C:\> Connect-VIServer vcenter.lab.com –User vcadmin@lab.com –Password Vmware1!
Adding hosts to a vCenter server

Note that I have provided all the parameter values in the command line itself; if you omit them, then it will display a popup asking for the user ID and password.

There's a better way of providing passwords to a connection: using the –Credential option and with PSCredential ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required