A simple guide to getting started with powercli
PowerCLI is a default scripting tool from VMware used to manage and automate the entire portfolio of VMware products, this is based on Powershell.
The easiest way to install powercli module is by running this command on your powershell
PS> Install-Module VMware.PowerCLI
Import powercli module using the below command
Import-Module VMware.PowerCLI
Verify if powercli modules are loading correctly using the below command
Get-Module -ListAvailable VMware*
Connect to vCenter
We can now attempt to use PowerCLI to connect to vCenter or ESX with the Connect-VIServer cmdlet.
PS> Connect-VIServer <FQDN of vCenter Server or ESXi Host>
On the powershell ISE, we could create a script as shown.
Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
Import-Module VMware.VimAutomation.Core
Import-Module VMware.VimAutomation.core
Import-MOdule VMware.VimAutomation.Common
$credVC = get-credential administrator@vsphere.local
#$credESX = get-credential root
$vc = Connect-VIServer -Server <>-Credential $credVC
Connect-VIServer -Server <IP of DNS name of Vcenter> -user <NETBIOSDomain\username> -password <password>