Get-Network Switch Vlan

Gets VLANs for a network switch.

Syntax

Get-NetworkSwitchVlan
   -CimSession <CimSession>
   [-Name <String>]
   [<CommonParameters>]
Get-NetworkSwitchVlan
   -CimSession <CimSession>
   -VlanId <Int32>
   [<CommonParameters>]
Get-NetworkSwitchVlan
   -CimSession <CimSession>
   -InstanceId <String>
   [<CommonParameters>]
Get-NetworkSwitchVlan
   -CimSession <CimSession>
   -Caption <String>
   [<CommonParameters>]
Get-NetworkSwitchVlan
   -CimSession <CimSession>
   -Description <String>
   [<CommonParameters>]

Description

The Get-NetworkSwitchVlan cmdlet gets available virtual local area networks (VLANs) for a network switch.

Examples

Example 1: Get all VLANs for a network switch

PS C:\>$Session = New-CimSession -ComputerName "NetworkSwitch08"
PS C:\> Get-NetworkSwitchVlan -CimSession $Session
Caption             Description         Name                InstanceID                       VlanID PSComputerName    
-------             -----------         -----------         ----------                       ------ --------------    
                    Vlan_description    default             Contoso:NetworkVL...                   1 10.19.246.18     
                    Vlan_description    VLAN0002            Contoso:NetworkVL...                   2 10.19.246.18

The first command creates a CimSession for a network switch, and then stores it in the $Session variable. For more information about CimSession objects, type Get-Help New-CimSession .

The second command gets all VLAN for the switch NetworkSwitch08 by using the $Session object.

Example 2: Get a VLAN by using a name

PS C:\>Get-NetworkSwitchVlan -CimSession $Session -Name "VLAN22"
Caption             Description         Name                InstanceID                       VlanID PSComputerName    
-------             -----------         -----------         ----------                       ------ --------------    
                    Vlan_description    VLAN22              Contoso:NetworkVL...                   1 10.19.236.49

This command gets the VLAN named VLAN22. The command includes a CimSession , similar to the first example.

Required Parameters

-Caption

Specifies the caption of a VLAN to get.

Type: String
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-CimSession

Specifies the CimSession that this cmdlet uses to connect to the network switch. For more information about CimSession objects, type Get-Help New-CimSession .

Type: CimSession
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-Description

Specifies the description of a VLAN to get.

Type: String
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-InstanceId

Specifies the instance ID of a VLAN to get.

Type: String
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
-VlanId

Specifies the VLAN ID of the VLAN to get.

Type: Int32
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Optional Parameters

-Name

Specifies the name of a VLAN to get. This ElementName is a friendly name. It is not necessarily unique.

Type: String
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Inputs

None

Outputs

CimInstance[]

This cmdlet returns an array of CimInstance objects for network switch VLANs.