VMware vSphere 5.0 Documentation

VMware vSphere 5.0 Documentation


Virtual Machine PowerCLI commands

Connect to vCenter server using PowerCLI

Connect-VIServer –Server –Protocol https –User administrator –Password mdp1234

Get list of VM’s


Get list of VM’s, sorted by name

Get-VM | Sort -Property Name

Get VM within a specific vApp

Get-VM -Location (Get-vApp “vApp name”)

Get VM guest OS info (IP address, etc)

Get-VMGuest -VM (Get-VM -Name MyVM)

Get list of VM’s and their UUID’s

Get-VM -Name “MyVM” | %{(Get-View $_.Id).config.uuid}

Get list of virtual machine config file paths in a particular vApp

Get-VM -Location (Get-vApp “vApp Name”) | Get-View | %{$_.Config.Files.VmPathName} | Sort

Get Power On/Off times and events for VM

Get-VM MyVM | Get-VIEvent | Where {$_.fullFormattedMessage -like “*Power*”}

Storage vMotion (SvMotion) a VM to a different datastore.

Get-VM MyVM | Move-VM -datastore (Get-datastore “DestinationDatastore”)

Move VMs to New PortGroup Network

Get-VM -Location (Get-Folder “InThisFolder”) | Get-NetworkAdapter | Where {$_.NetworkName -eq “Network A”} | Set-NetworkAdapter -NetworkName “Network B” -Confirm:$false

Sends OS shutdown command via VM Tools

Shutdown-VMGuest -VM (Get-VM -name “vserver1″)

Get Snapshot size, date created, and other info for a VM

Get-VM MyVM | Get-Snapshot | Select-Object -Property Name, Description, Created, SizeMB | Format-List *