Get-VM
This cmdlet retrieves the virtual machines on a vCenter Server system. 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.
Syntax
[-Location <VIContainer[]>]
[-Name <String[]>]
[-NoRecursion]
[-Server <VIServer[]>]
[-Tag <Tag[]>]
[CommonParameters]
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
optional |
|
StorageResource[] | named |
|
Specifies datastores or datastore clusters 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. | optional |
|
VIContainer[] | named |
|
Specifies vSphere container objects you want to search for virtual machines. Supported container object types are: ResourcePool, VApp, VMHost, Folder, Cluster, Datacenter. | optional |
|
String[] | named |
|
Specifies the names of the virtual machines you want to retrieve. | optional |
|
SwitchParameter | named |
|
Indicates that you want to deactivate the recursive behavior of the command. | optional |
|
VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. | optional |
|
Tag[] | named |
|
Returns only the virtual machines that are associated with any of the specified tags. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required |
|
String[] | named |
|
Specifies the IDs of the virtual machines you want to retrieve. Note: When a list of values is specified for the Id parameter, the returned objects would have an ID that matches exactly one of the string values in that list. | optional |
|
VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. |
[-Server <VIServer[]>]
[-Tag <Tag[]>]
[-VirtualSwitch <VirtualSwitchBase[]>]
[CommonParameters]
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
optional |
|
String[] | named |
|
Specifies the names of the virtual machines you want to retrieve. | optional |
|
VIServer[] | named |
|
Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is provided or $null value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. | optional |
|
Tag[] | named |
|
Returns only the virtual machines that are associated with any of the specified tags. | optional |
|
VirtualSwitchBase[] | named |
|
When specified, the cmdlet returns only the virtual machines that have network adapters attached to the specified switches. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required |
|
VmRelatedObjectBase[] | named |
|
Specifies objects to retrieve one or more vSphere VirtualMachine objects that are related to them. This parameter accepts vCloud CIVM and OMResource objects. |
Output
VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachine
Examples
Example 1
Retrieves all virtual machines whose names starting with "MyVM".
Example 2
Retrieves all virtual machines that reside on the specified datastore.
Example 3
Retrieves all virtual machines in the specified datacenter.
Example 4
Retrieves all virtual machines connected to the specified distributed switch.
Related Commands
VM
VMConsoleWindow
VMGuest
VMGuestDisk
VMGuestFile
VMQuestion
VMResourceConfiguration
VMScript