vSphere PowerCLI Cmdlets Reference

Get-VM

Synopsis

Retrieves the virtual machines on a vSphere server.

Syntax

Get-VM [-Datastore <Datastore[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
Get-VM [-DistributedSwitch <DistributedSwitch[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]

Related Commands

Online version
Remove-VM
New-VM
Set-VM
Move-VM
Start-VM
Stop-VM
Suspend-VM
Restart-VM

Detailed Description

Retrieves the virtual machines on a vSphere server. Returns a set of virtual machines that correspond to the filter criteria provided by the cmdlet parameters. For virtual machines with multiple NICs and multiple IP addresses, the IPAddress property of the VMGuest object contains all IP addresses of the virtual machine. The IP at position 0 is the primary IP address.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
NameString[]Specify the names of the virtual machines you want to retrieve.falsefalse
DatastoreDatastore[]Specify datastores to filter the virtual machines associated with them. Passing values to this parameter through a pipeline is deprecated and will be removed in a future release.falsetrue (ByValue)
DistributedSwitchDistributedSwitch[]Filter the available virtual machines by the virtual switches they are connected to.falsetrue (ByValue)
IdString[]Specify the IDs of the virtual machines you want to retrieve.falsefalse
LocationVIContainer[]Specify vSphere container objects (such as folders, datacenters, and clusters) you want to search for virtual machines.falsetrue (ByValue)
NoRecursionSwitchParameterIndicate that you want to disable the recursive behavior of the command.falsefalse
ServerVIServer[]One or more vSphere servers to apply the command on. If no value is given to this parameter, the command runs on the server currently specified in the $DefaultVIServer variable.falsefalse

Return Type

VirtualMachine

Notes

Examples

-------------- EXAMPLE 1 --------------

Get-VM

Retrieves information about all of the virtual machines registered with the currently selected vSphere server.

-------------- EXAMPLE 2 --------------

Get-VM -Name VM*

This command retrieves information about all virtual machines registered with the currently-selected vSphere server whose names begin with "VM".


Copyright © 1998 - 2010 VMware, Inc. All rights reserved.