vSphere PowerCLI Reference

Get-VirtualSwitch

Synopsis

Retrieves the virtual switches associated with a virtual machine host or used by a virtual machine.

Syntax

Get-VirtualSwitch [-Id <String[]>] [[-VMHost] <VMHost[]>] [[-VM] <VirtualMachine[]>] [-Datacenter <Datacenter[]>] [-Name <String[]>] [-Standard] [-Distributed] [-Server <VIServer[]>] [<CommonParameters>]

Related Commands

Online version
New-VirtualSwitch
Remove-VirtualSwitch
Set-VirtualSwitch

Detailed Description

Retrieves the virtual switches associated with a virtual machine host or used by a virtual machine. At least one of the VMHost and VM parameters must be provided. The VM, VMHost, Name parameters do not accept string values through a pipeline because of collision. To specify a server different from the default one, use the -Server parameter.

Parameters

NameTypeDescriptionRequired?Pipeline InputDefault Value
VMHostVMHost[]Specify the hosts whose virtual switches you want to retrieve. The position of this parameter is deprecated and will be changed in a future release. To avoid errors when you run existing scripts on future PowerCLI versions, specify the parameter by name.falsetrue (ByValue)
VMVirtualMachine[]Specify the virtual machines whose virtual switches you want to retrieve.falsetrue (ByValue)
DatacenterDatacenter[]Filter the virtual switches connected to hosts in the specified datacenters.falsetrue (ByValue)
DistributedSwitchParameterIndicate that you want to retrieve only DistributedSwitch objects.falsefalse
IdString[]Specify the Ids of the virtual switches you want to retrieve.falsefalse
NameString[]Specify the names of the virtual switches you want to retrieve. Passing values to this parameter through a pipeline is deprecated and will be disabled in a future release. The position of this parameter is deprecated and will be changed in a future release. To avoid errors when you run existing scripts on future PowerCLI versions, specify the parameter by name.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
StandardSwitchParameterIndicate that you want to retrieve only VirtualSwitch objects.falsefalse

Return Type

VirtualSwitchBase or DistributedSwitch

Notes

Examples

-------------- Example 1 --------------

Get-VirtualSwitch -VM VM

Retrieves the virtual switch used by the virtual machine named VM.


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