VMware PowerCLI 6.5.1
Date : April 2017
Installation
From Powershell Gallery
Install-Module ‑Name VMware.PowerCLI –Scope CurrentUser
Offline installation
Save-Module ‑Name VMware.PowerCLI ‑Path C:\Path\To\Desired\Folder
... then copy content to the target machine in folder: "$home\Documents\WindowsPowerShell\Modules"
Load module
Import-Module VMware.PowerCLI
Connections
Enter credentials in a windows popup
Connect-VIServer ‑Server <server> ‑credential $(Get-Credential)
Host management
Add a new ESXi to the inventory
Add-VMHost <fqdn or ip> ‑Location (Get-Cluster <cLustername>) ‑User root ‑Password <password>
Set a host to maintenand mode
Set-VMHost ‑VMHost <host> ‑State "Maintenance"
Power operations on ESXi
Restart-VMHost ‑VMHost <host>
Stop-VMHost ‑VMHost <host>
Retrieves information about host services
Get-VMHostService <host>
Restart a specific host service
Get-VMHostService <host> | ? {($_.Key ‑eq "TSM-ssh")} | Restart-VMHostService
Cluster management
Get cluster information
Get-Cluster ‑Name <clustername>
Enable HA on cluster
Set-Cluster ‑Cluster <cluster> ‑HAEnabled:$true ‑HAAdmissionControlEnabled:$true
Enable DRS on cluster
Set-Cluster ‑Cluster <cluster> ‑DRSEnabled:$true ‑DRSAutomationLevel "FullyAutomated"
Set EVC mode on cluster
Set-Cluster ‑Cluster <cluster> ‑EVCMode "intel-nehalem"
vApp management
Export a vApp in OVA format
Export-VApp ‑vApp <vapp> ‑Destination "c:\vapps\" ‑Format Ova
Import OVA file as vApp
Import-vApp ‑Source "c:\vapps\appliance.ova" ‑Datastore <datastore> ‑VMHost <vmhost>
Configure memory ressources for a vApp
Set-VApp ‑VApp <vapp> ‑MemExpandableReservation:$true ‑MemReservationGB 2 ‑MemLimitGB 4