Previous posts of this blog series talked about how to install PowerCLI, connecting to ESXi host and basics of working with the vCenter server. In this article, we will go through basic VM operations.
Get basic VM details:
Get-VM -Name <name of the virtual machine>
To view all properties of a VM object:
Get-VM -Name <name of the virtual machine> | Get-Member
To start a VM:
Get-VM -Name <name of the virtual machine> | Start-VM
Get-VM -Name <name of the virtual machine> | Restart-VMGuest
Get-VM -Name <name of the virtual machine> | Shutdown-VMGuest
Get-VM -Name <name of the virtual machine> | Remove-VM -DeletePermanently
Let's have a look into the "ExtensionData" property of a virtual machine.
Status related details of a VM:
(Get-VM -Name <name of the virtual machine>).ExtensionData | select GuestHeartbeatStatus,OverallStatus,ConfigStatus
CPU, Memory config details of a VM:
(Get-VM -Name <name of the virtual machine>).ExtensionData.Config.Hardware
CPU, Memory hot add/ remove features:
Layout details of a VM:
(Get-VM -Name <name of the virtual machine>).ExtensionData.LayoutEx.File | sort Key | ft
VM tools status and other guest details:
(Get-VM -Name <name of the virtual machine>).ExtensionData.Guest
Network related info of a VM:
(Get-VM -Name <name of the virtual machine>).ExtensionData.Guest.Net
Hope this was useful. Cheers!