Syntax
Get-VMHost [-Datastore <Datastore[]>] [-State <VMHostState[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]Related Commands
Online versionDetailed Description
Retrieves the hosts on a vSphere server. Returns a set of hosts that correspond to the filter criteria provided by the cmdlet parameters. To specify a server different from the default one, use the -Server parameter.Parameters
| Name | Type | Description | Required? | Pipeline Input | Default Value |
|---|---|---|---|---|---|
| Name | String[] | Specify the names of the hosts you want to retrieve. | false | false | |
| Datastore | Datastore[] | Specify the datastores to which the hosts that you want to retrieve are associated. 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 hosts by the virtual switches they are connected to. | false | true (ByValue) | |
| Id | String[] | Specify the IDs of the hosts you want to retrieve. | false | false | |
| Location | VIContainer[] | Specify the vSphere container objects (such as folders, datacenters, and clusters) you want to search for hosts. | false | true (ByValue) | |
| NoRecursion | SwitchParameter | Indicate that you want to disable the recursive behavior of the command. | false | false | |
| ResourcePool | ResourcePool[] | Specify resource pools associated with the hosts you want to retrieve. | false | false | |
| Server | VIServer[] | Specify the vSphere servers on which you want to run the cmdlet. If no value is given to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. | false | false | |
| State | VMHostState[] | Specify the state of the hosts you want to retrieve. The valid values are Connected, Disconnected, NotResponding, and Maintenance. | false | false | |
| VM | VirtualMachine[] | Specify virtual machines whose hosts you want to retrieve. | false | true (ByValue) |
Return Type
VMHostNotes
When working directly on an ESX host, the Name property of the returned VMH ost object contains either the DNS name or the IP of the ESX host, dependi ng on which of them was specified when connecting with Connect-VIServer.Examples
-------------- Example 1 --------------
Get-VMHost -Location Datacenter -VM VM | fl
Retrieves the host, which is located in the datacenter named Datacenter and on which the VM virtual machine is hosted.