< Back
Get-VMHost
Post
NAME Get-VMHost
SYNOPSIS
This cmdlet retrieves the hosts on a vCenter Server system.
SYNTAX
Get-VMHost [[-Name] <String[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>] [-NoRecursion]
[-Server <VIServer[]>] [-State <VMHostState[]>] [-Tag <Tag[]>] [<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>] [-NoRecursion]
[-ResourcePool <ResourcePool[]>] [-Server <VIServer[]>] [-Tag <Tag[]>] [-VM <VirtualMachine[]>]
[<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-DistributedSwitch <DistributedSwitch[]>] [-Server <VIServer[]>] [-Tag <Tag[]>]
[<CommonParameters>]
Get-VMHost -Id <String[]> [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [-RelatedObject] <VMHostRelatedObjectBase[]> [<CommonParameters>]
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
-Datastore <StorageResource[]>
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.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-DistributedSwitch <DistributedSwitch[]>
Filters the available hosts by the virtual switches they are connected to.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-Id <String[]>
Specifies the IDs of the hosts 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.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Location <VIContainer[]>
Specifies the vSphere container objects (such as folders, datacenters, and clusters) you want to search for
hosts.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-Name <String[]>
Specifies the names of the hosts you want to retrieve.
Required? false
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-NoRecursion [<SwitchParameter>]
Indicates that you want to disable the recursive behavior of the command.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-RelatedObject <VMHostRelatedObjectBase[]>
Specifies objects to retrieve one or more VMHost objects that are related to them. This parameter accepts
OMResource objects.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-ResourcePool <ResourcePool[]>
Specifies resource pools associated with the hosts you want to retrieve.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Server <VIServer[]>
Specifies the vCenter Server systems 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-State <VMHostState[]>
Specifies the state of the hosts you want to retrieve. The valid values are Connected, Disconnected,
NotResponding, and Maintenance.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tag <Tag[]>
Returns only the virtual machine hosts that are associated with any of the specified tags.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-VM <VirtualMachine[]>
Specifies virtual machines whose hosts you want to retrieve.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Zero or more VMHost objects
NOTES
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.
-------------------------- 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.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... MHost.html
Add-VMHost
Move-VMHost
Remove-VMHost
Restart-VMHost
Set-VMHost
Start-VMHost
Stop-VMHost
Suspend-VMHost
SYNOPSIS
This cmdlet retrieves the hosts on a vCenter Server system.
SYNTAX
Get-VMHost [[-Name] <String[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>] [-NoRecursion]
[-Server <VIServer[]>] [-State <VMHostState[]>] [-Tag <Tag[]>] [<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-Datastore <StorageResource[]>] [-Location <VIContainer[]>] [-NoRecursion]
[-ResourcePool <ResourcePool[]>] [-Server <VIServer[]>] [-Tag <Tag[]>] [-VM <VirtualMachine[]>]
[<CommonParameters>]
Get-VMHost [[-Name] <String[]>] [-DistributedSwitch <DistributedSwitch[]>] [-Server <VIServer[]>] [-Tag <Tag[]>]
[<CommonParameters>]
Get-VMHost -Id <String[]> [-Server <VIServer[]>] [<CommonParameters>]
Get-VMHost [-RelatedObject] <VMHostRelatedObjectBase[]> [<CommonParameters>]
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
-Datastore <StorageResource[]>
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.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-DistributedSwitch <DistributedSwitch[]>
Filters the available hosts by the virtual switches they are connected to.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-Id <String[]>
Specifies the IDs of the hosts 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.
Required? true
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Location <VIContainer[]>
Specifies the vSphere container objects (such as folders, datacenters, and clusters) you want to search for
hosts.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
-Name <String[]>
Specifies the names of the hosts you want to retrieve.
Required? false
Position? 1
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-NoRecursion [<SwitchParameter>]
Indicates that you want to disable the recursive behavior of the command.
Required? false
Position? named
Default value False
Accept pipeline input? False
Accept wildcard characters? false
-RelatedObject <VMHostRelatedObjectBase[]>
Specifies objects to retrieve one or more VMHost objects that are related to them. This parameter accepts
OMResource objects.
Required? true
Position? 1
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? false
-ResourcePool <ResourcePool[]>
Specifies resource pools associated with the hosts you want to retrieve.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-Server <VIServer[]>
Specifies the vCenter Server systems 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.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-State <VMHostState[]>
Specifies the state of the hosts you want to retrieve. The valid values are Connected, Disconnected,
NotResponding, and Maintenance.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? false
-Tag <Tag[]>
Returns only the virtual machine hosts that are associated with any of the specified tags.
Required? false
Position? named
Default value None
Accept pipeline input? False
Accept wildcard characters? true
-VM <VirtualMachine[]>
Specifies virtual machines whose hosts you want to retrieve.
Required? false
Position? named
Default value None
Accept pipeline input? True (ByValue)
Accept wildcard characters? true
<CommonParameters>
This cmdlet supports the common parameters: Verbose, Debug,
ErrorAction, ErrorVariable, WarningAction, WarningVariable,
OutBuffer, PipelineVariable, and OutVariable. For more information, see
about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).
INPUTS
OUTPUTS
Zero or more VMHost objects
NOTES
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.
-------------------------- 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.
RELATED LINKS
Online Version: https://code.vmware.com/doc/preview?id= ... MHost.html
Add-VMHost
Move-VMHost
Remove-VMHost
Restart-VMHost
Set-VMHost
Start-VMHost
Stop-VMHost
Suspend-VMHost