Syntax
Get-VM [-Datastore <Datastore[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]Related Commands
Online versionDetailed 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
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Name | String[] | Specify the names of the virtual machines you want to retrieve. | false | false | |
| Datastore | Datastore[] | 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. | false | true (ByValue) | |
| DistributedSwitch | DistributedSwitch[] | Filter the available virtual machines by the virtual switches they are connected to. | false | true (ByValue) | |
| Id | String[] | Specify the IDs of the virtual machines you want to retrieve. | false | false | |
| Location | VIContainer[] | Specify vSphere container objects (such as folders, datacenters, and clusters) you want to search for virtual machines. | false | true (ByValue) | |
| NoRecursion | SwitchParameter | Indicate that you want to disable the recursive behavior of the command. | false | false | |
| Server | VIServer[] | 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. | false | false |
Return Type
VirtualMachineNotes
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".