vSphere PowerCLI Reference

Get-VMHost

Synopsis

This cmdlet retrieves the hosts on a vCenter Server system.

Syntax

Get-VMHost [[-Name] <String[]>] [-NoRecursion] [-Datastore <StorageResource[]>] [-State <VMHostState[]>] [-Location <VIContainer[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-DistributedSwitch <DistributedSwitch[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-NoRecursion] [-VM <VirtualMachine[]>] [-ResourcePool <ResourcePool[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>] [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost -Id <String[]> [-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

This cmdlet retrieves the hosts on a vCenter Server system. 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[]Specifies the names of the hosts you want to retrieve.falsefalse
DatastoreStorageResource[]Specifies the datastores or datastore clusters 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[]Filters the available hosts by the virtual switches they are connected to.falsetrue (ByValue)
IdString[]Specifies the IDs of the hosts you want to retrieve.truefalse
LocationVIContainer[]Specifies the vSphere container objects (such as folders, datacenters, and clusters) you want to search for hosts.falsetrue (ByValue)
NoRecursionSwitchParameterIndicates that you want to disable the recursive behavior of the command.falsefalse
ResourcePoolResourcePool[]Specifies resource pools associated with the hosts you want to retrieve.falsefalse
ServerVIServer[]Specifies the vCenter Server instances on which you want to run the cmdlet. If no 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.falsefalse
StateVMHostState[]Specifies the state of the hosts you want to retrieve. The valid values are Connected, Disconnected, NotResponding, and Maintenance.falsefalse
VMVirtualMachine[]Specifies virtual machines whose hosts you want to retrieve.falsetrue (ByValue)

Return Type

Zero or more VMHost objects

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 MyDatacenter

Retrieves all hosts in the specified datacenter.

-------------- Example 2 --------------

$MyVM = Get-VM -Name MyVM
Get-VMHost -VM $MyVM

Retrieves the host on which the specified virtual machine runs.

-------------- Example 3 --------------

$myVDSwitch = Get-VDSwitch -Name "MyVDSwitch"
Get-VMHost -DistributedSwitch $myVDSwitch

Retrieves all hosts associated with the specified vSphere distributed switch.


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