Get details of a virtual machine using PowerCLI

There are two critical steps to complete before you get started.

  1. Make sure you configure PowerShell to allow remote script execution. set-executionpolicyremotesigned
  2. Connect to your vCenter server or to an individual ESX/ESXi host. Connect-VIServer -Server -Protocol https -User root -Password passwordgoeshere

Gather additional details about a running virtual machine isn’t an arduous process using PowerShell, but there are some ways that you can make your life easier as you move forward. In order to the process a bit easier, we’ll actually assign the results of the get-vm command, which we discussed in part 1 of this series, to a variable that we can then manipulate to get the information we want. By learning how to, for example, list the hard disks associated with a virtual machine, you’ll be able to get better statistics down the line.

To assign all of a single virtual machine’s properties to a variable, use a syntax like the following:

$v = get-vm win7-usb

This will assign all of the results from the get-vm win7-usb command to the newly created variable named $v. Ideally, in the real world, you’ll use more descriptive variable names, but to keep things a little clearer for demonstration purposes, I’m using shorter names.

This is a “point in time” snapshot of how the virtual machine looked at the time its information was committed to the variable named $v. If you make configuration changes later on, you need to run the same command again to update the variable’s contents.

Now, let’s get a little bit of information about what’s been assigned to this variable. In order to do so, let’s start with something basic. Simply execute the command $v with no parameters. You will get something similar to the result shown in the figure below.

Figure 2: A high level look at the VM

Because we’ve assigned the results of the get-vm command to the variable named $v, you see the VM stats by executing just $v.

Now, suppose you want to see the network adapters assigned to this virtual  machine.  “NetworkAdapters” is a property for the newly created $v variable by virtue of the fact that we’ve assigned VM configuration information to it.

To get the properties of the network adapters in the virtual machine, execute the command $v.NetworkAdapters.


There are a lot of other properties that you can get from a virtual machine, too, including:

  • CDDrives
  • CustomFields
  • DrsAutomationLevel
  • ExtensionData
  • FloppyDrives
  • Folder
  • FolderID
  • Guest
  • HAIsolationResponse
  • HardDisks
  • HARestartPriority
  • Host
  • HostId
  • Id
  • MemoryMB
  • Name
  • NetworkAdapters
  • Notes
  • NumCpu
  • PersistentId
  • PowerState
  • ProvisionedSpaceGB
  • ResourcePool
  • ResourcePoolId
  • Uid
  • UsbDevices
  • UsedSpaceGB
  • VApp
  • Version
  • VMhost
  • VMHostID
  • VMResourceConfiguration
  • VMSwapfilePolicy

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top