vSphere PowerCLI Cmdlets Reference

Get-VMHost

Synopsis

Retrieves the hosts on a vSphere server.

Syntax

Get-VMHost [-Datastore <Datastore[]>] [-State <VMHostState[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [-VM <VirtualMachine[]>] [-ResourcePool <ResourcePool[]>] [-Datastore <Datastore[]>] [-Location <VIContainer[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [-DistributedSwitch <DistributedSwitch[]>] [[-Name] <String[]>] [-Id <String[]>] [-NoRecursion] [-Server <VIServer[]>] [<CommonParameters>]

Related Commands

Online version
Add-VMHost
Move-VMHost
Remove-VMHost
Restart-VMHost
Set-VMHost
Start-VMHost
Stop-VMHost
Suspend-VMHost

Detailed 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.
When working directly on an ESX host, the Name property of the returned VMHost object contains either the DNS name or the IP of the ESX host, depending on which of them was specified when connecting with Connect-VIServer.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
NameString[]Specify the names of the hosts you want to retrieve.falsefalse
DatastoreDatastore[]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.falsetrue (ByValue)
DistributedSwitchDistributedSwitch[]Filter the available hosts by the virtual switches they are connected to.falsetrue (ByValue)
IdString[]Specify the IDs of the hosts you want to retrieve.falsefalse
LocationVIContainer[]Specify the vSphere container objects (such as folders, datacenters, and clusters) you want to search for hosts.falsetrue (ByValue)
NoRecursionSwitchParameterIndicate that you want to disable the recursive behavior of the command.falsefalse
ResourcePoolResourcePool[]Specify resource pools associated with the hosts you want to retrieve.falsefalse
ServerVIServer[]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.falsefalse
StateVMHostState[]Specify the state of the hosts you want to retrieve. The valid values are Connected, Disconnected, NotResponding, and Maintenance.falsefalse
VMVirtualMachine[]Specify virtual machines whose hosts you want to retrieve.falsetrue (ByValue)

Return Type

VMHost

Notes

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 datacenter and on which the VM virtual machine is hosted.


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