Manage VMWare ESX with PowerShell


Yes, you can manage VMWare host with PowerShell, even stand alone ESXi.

First, you need to download “VMware vSphere PowerCLI“.

And then, you can do something like this :

Add-PSSnapin vmware.vimautomation.core
Connect-VIServer HOST1,HOST2,HOST3 -User root -Password root
Get-VM | % {
$Obj = New-Object PSObject -Property @{
'Hote'       = $_.VMHost
'VMName'     = $_.Name
'Version VM' = $_.Version
'vCPU'       = $_.NumCpu
'RAM (GB)'   = $_.MemoryGB
'Disk1'      = $_.harddisks[0].CapacityGB
'Disk2'      = $_.harddisks[1].CapacityGB
'Disk3'      = $_.harddisks[2].CapacityGB
'Disk4'      = $_.harddisks[3].CapacityGB
Write-Output $Obj
} | Out-GridView

You can have a look at all the cmdlets available : (You need to add the snapin before)

Get-Command -Module vmware.vimautomation.core




Leave a Reply