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
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
required
|
Id | 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 | ProgressAction | ActionPreference | named |
|
|
optional | Server | 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. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
optional | Datastore | 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 | Location | 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 | Name | String[] | named |
|
Specifies the names of the virtual machines you want to retrieve. |
optional | NoRecursion | SwitchParameter | named |
|
Indicates that you want to deactivate the recursive behavior of the command. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | Server | 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 | Tag[] | named |
|
Returns only the virtual machines that are associated with any of the specified tags. |
Parameters
Required | Parameter Name | Type | Position | Features | Description |
---|---|---|---|---|---|
optional | Name | String[] | named |
|
Specifies the names of the virtual machines you want to retrieve. |
optional | ProgressAction | ActionPreference | named |
|
|
optional | Server | 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 | Tag[] | named |
|
Returns only the virtual machines that are associated with any of the specified tags. |
optional | VirtualSwitch | 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
|
RelatedObject | 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. |
optional | ProgressAction | ActionPreference | named |
|
Output
VMware.VimAutomation.ViCore.Types.V1.Inventory.VirtualMachineExamples
Example 1
Get-VM -Name MyVM*
Retrieves all virtual machines whose names starting with "MyVM".
Example 2
$myDatastore = Get-Datastore -Name "MyDatastore" Get-VM -Datastore $myDatastore
Retrieves all virtual machines that reside on the specified datastore.
Example 3
$myDatacenter = Get-Datacenter -Name "MyDatacenter" Get-VM -Location $myDatacenter
Retrieves all virtual machines in the specified datacenter.
Example 4
$myVDSwitch = Get-VDSwitch -Name "MyVDSwitch" Get-VM -DistributedSwitch $myVDSwitch
Retrieves all virtual machines connected to the specified distributed switch.
Related Commands
VM
This cmdlet retrieves the virtual machines on a vCenter Server system.
This cmdlet moves virtual machines to another location.
This cmdlet creates a new virtual machine.
This cmdlet removes the specified virtual machines from the vCenter Server system.
This cmdlet restarts the specified virtual machines.
This cmdlet modifies the configuration of the virtual machine.
This cmdlet powers on virtual machines.
This cmdlet powers off virtual machines.
This cmdlet suspends virtual machines.
This cmdlet unlocks the specified virtual machine.
VMConsoleWindow
This cmdlet opens a window to the virtual machine's console.
VMGuest
This cmdlet retrieves the guest operating systems of the specified virtual machines.
This cmdlet restarts the virtual machine guest operating systems.
This cmdlet shuts down the specified virtual machine guest OS.
This cmdlet suspends the specified guest operating systems.
VMGuestDisk
This cmdlet retrieves storage volumes as seen by the virtual machines' guest operating systems.
VMGuestFile
This cmdlet copies files and folders from and to the guest OS of the specified virtual machines using VMware Tools.
VMQuestion
This cmdlet retrieves the pending questions for the specified virtual machines.
This cmdlet answers the specified virtual machine question.
VMResourceConfiguration
This cmdlet retrieves information about the resource allocation between the selected virtual machines.
This cmdlet configures resource allocation between the virtual machines.
VMScript
This cmdlet runs a script in the guest OS of each of the specified virtual machines.
VMStartPolicy
This cmdlet retrieves the start policy of the virtual machines on a vCenter Server system.
This cmdlet modifies the virtual machine start policy.