< Back

Get-VirtualSwitch

Sun Jan 19, 2020 6:54 pm

NAME Get-VirtualSwitch



SYNOPSIS

This cmdlet retrieves the virtual switches associated with a virtual machine host or used by a virtual machine.





SYNTAX

Get-VirtualSwitch [[-VMHost] <VMHost[]>] [[-VM] <VirtualMachine[]>] [-Datacenter <Datacenter[]>] [-Distributed]

[-Name <String[]>] [-Server <VIServer[]>] [-Standard] [<CommonParameters>]



Get-VirtualSwitch -Id <String[]> [-Server <VIServer[]>] [<CommonParameters>]



Get-VirtualSwitch -RelatedObject <VirtualSwitchRelatedObjectBase[]> [<CommonParameters>]





DESCRIPTION

This cmdlet 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

-Datacenter <Datacenter[]>

Filters the virtual switches connected to hosts in the specified datacenters.



Required? false

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-Distributed [<SwitchParameter>]

Indicates that you want to retrieve only DistributedSwitch objects. This parameter is obsolete. To retrieve

distributed switches, use the Get-VDSwitch cmdlet instead.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-Id <String[]>

Specifies the IDs of the virtual switches 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



-Name <String[]>

Specifies 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.



Required? false

Position? named

Default value None

Accept pipeline input? False

Accept wildcard characters? true



-RelatedObject <VirtualSwitchRelatedObjectBase[]>

Specifies objects to retrieve one or more VirtualSwitch objects that are related to them. This parameter

accepts vCloud NetworkPool objects.



Note: In vCloud Director 5.1 environments, you cannot retrieve a distributed switch from a network pool backed

by the distributed switch.



Required? true

Position? named

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? false



-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



-Standard [<SwitchParameter>]

Indicates that you want to retrieve only VirtualSwitch objects.



Required? false

Position? named

Default value False

Accept pipeline input? False

Accept wildcard characters? false



-VM <VirtualMachine[]>

Specifies the virtual machines whose virtual switches you want to retrieve.



Required? false

Position? 2

Default value None

Accept pipeline input? True (ByValue)

Accept wildcard characters? true



-VMHost <VMHost[]>

Specifies 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.



Required? false

Position? 1

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 VirtualSwitchBase objects







NOTES





This cmdlet retrieves standard switches. Retrieving distributed switches with this cmdlet is obsolete. Use the

Get-VDSwitch cmdlet instead.



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



Get-VirtualSwitch -VM VM



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

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



Get-Datacenter -Name "MyDatacenter" | Get-VirtualSwitch



Retrieves all virtual switches in the specified datacenter.

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



Get-VMHost -Name "MyVMHost" | Get-VirtualSwitch



Retrieves all virtual switches on the specified host.

-------------------------- Example 4 --------------------------



Get-VirtualSwitch -Name "vSwitch0"



Retrieves all virtual switches named "vSwitch0".



RELATED LINKS

Online Version: https://code.vmware.com/doc/preview?id= ... witch.html

New-VirtualSwitch

Remove-VirtualSwitch

Set-VirtualSwitch