VMWare PowerCLI Guide: How to Install and Use?

PowerCLI for VMware vSphere is an incredibly powerful tool based on Microsoft PowerShell. PowerCLI allows you to centrally manage the ESXi and vCenter servers from the command line and allows to perform up to 98% of virtual infrastructure routine management tasks without GUI. Using the utility PowerCLI it is possible to create scripts, monitor the state of virtual machines, storages, networks, users and automate a number of processes.

PowerCLI includes more than 1900 cmdlets to manage the VMware cloud and virtual infrastructure: vSphere, vSAN, vRealize Operations Manager, vCloud Director, Site Recovery Manager, Horizon and vCloud Air. When executing cmdlets, the API is invoked on the specified ESXi server or vCenter server and performs operations on this remote server.

PowerCLI can be installed on computers with Microsoft Windows 7/Windows Server 2008 R2 and higher, Ubuntu.

You can download the latest version of VMware PowerCLI 6.5 from the VMWare website (registration is required).


Installing VMWare PowerCLI does not require any special comments – just click Next button.

vsphere powercli

If you don’t want to install a thick PowerCLI client, you can install the VMware.PowerCLI module from the Internet using the following PowerShell command:

Install-Module -Name VMware.PowerCLI -AllowClobber -Force

To start the PowerCLI console, simply launch the VMWare VSphere PowerCLI shortcut as administrator.

vmware powercli

To display a list of available commands in the PowerCLI console, type:


vsphere powercli tool

You can get the list of commands for virtual machines in the way like this:

Get-Command *vm

For help with the assignment and showing solutions on how to use this or that PowerCLI cmdlet, you can use the help (Get-Help) command, for example:

help Connect–VIServer –Full

help Connect–VIServer –Examples

To start managing a virtual infrastructure, you need to connect to vCenter Server or a specific ESXi server. To do this, use the Connect-VIServer command. The connection command can look like this:

Connect-VIServer vsphere6 -User corp\admin -Password VMware1!

powercli tool

To get a list of virtual machines that are registered on your server, run the following command:


You can display only the powered on VMs:

Get-VM | Where {$_.Powerstate -eq “PoweredOn”} | Select Name, VMHost, NumCPU, MemoryMB| ft

vmware powercli tool

The list of virtual machines can be exported to the CSV, XML or HTML file using pipline and Export-Csv, ConvertTo-Xml, ConvertTo-Html cmdlets.

Note. PowerCLI works in read-only mode with the ESXi Free Hypervisor (a free license). This means that you can use it to view some properties and values, but you can’t change them.

You can list the snapshots for a particular VM like this:

Get-VM| Get-Snapshot| Format-List

To perform VMotion and move the running VM to another host, use the Move-VM command. For example, you want to move all VMs from the esxi1 host to the esxi2:

Get-VMHost esxi1|Get-Vm| Move-VM –Destination (Get-VMHost esxi2)

To create a new virtual machine, use the New-VM cmdlet:

New-VM –Name VMname1 -VMHost esxi1 –ResourcePool Production –DiskGB 20 –DiskStorageFormat Thin –Datastore MSAVMFS1

You can use the PowerCLI cmdlets to interact with the guest operating system, but VMware Tools must be installed on it. You can update VMware Tools like this:

Get-VMGuest VMname1 | Update-Tools

To copy a specific file to all VMs, run the following command:

Get-VM | Copy-VMGuestFile -Source c:\ps\script1.vbs -Destination c:\ps\ -GuestToLocal -HostUser root -HostPassword P@ssw0rd -GuestUser administrator -GuestPassword P@ssw0rd1

Using the Invoke-VMS cmdlet, you can run a script in the guest OS:

$script = '"%programfiles%\Common Files\Microsoft Shared\MSInfo\msinfo32.exe" /report "%tmp%\inforeport"'

Invoke-VMScript -ScriptText $script -VM VMname1 -HostCredential $hostCredential -GuestCredential $guestCredential -ScriptType Bat

Leave a Reply