< Back

Set-NetworkSwitchPortMode

Tue Jan 29, 2019 10:30 pm

NAME Set-NetworkSwitchPortMode



SYNOPSIS

Sets the port mode on a network switch.





SYNTAX

Set-NetworkSwitchPortMode [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable

<System.String>] -AccessMode -CimSession <CimSession> -VlanID <Int32> [<CommonParameters>]



Set-NetworkSwitchPortMode [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable

<System.String>] -CimSession <CimSession> -IpAddress <String> -RouteMode -SubnetAddress <String> [<CommonParameters>]



Set-NetworkSwitchPortMode [-InformationAction {SilentlyContinue | Stop | Continue | Inquire | Ignore | Suspend}] [-InformationVariable

<System.String>] -CimSession <CimSession> -TrunkMode -VlanIDs <UInt16[]> [<CommonParameters>]





DESCRIPTION

The Set-NetworkSwitchPortMode cmdlet sets the port mode to access, trunk or route on a network switch.





PARAMETERS

-AccessMode <SwitchParameter>

Indicates that this cmdlet sets the port to access mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



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



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-InformationAction [<System.Management.Automation.ActionPreference>]

Specifies how this cmdlet responds to an information event. The acceptable values for this parameter are:



-- SilentlyContinue

-- Stop

-- Continue

-- Inquire

-- Ignore

-- Suspend



Required? false

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-InformationVariable [<System.String>]

Specifies a variable in which to store an information event message.



Required? false

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-IpAddress <String>

Specifies an IP address to set for the port in route mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-RouteMode <SwitchParameter>

Indicates that this cmdlet sets the port to route mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-SubnetAddress <String>

Specifies the subnet mask to set for the port in route mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-TrunkMode <SwitchParameter>

Indicates that this cmdlet sets the port to trunk mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-VlanID <Int32>

Specifies the virtual local area network (VLAN) ID of the VLAN to set for the port in access mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



-VlanIDs <UInt16[]>

Specifies the VLAN IDs of the VLANs to set for the port in trunk mode.



Required? true

Position? named

Default value none

Accept pipeline input? false

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (http://go.microsoft.com/fwlink/?LinkID=113216).



INPUTS

CimInstance[]



You can pipe an array of CimInstance objects that correspond to a network switch port to this cmdlet.





OUTPUTS

None



This cmdlet does not generate any output.





Example 1: Set a port to trunk mode



PS C:\\>$Session = New-CimSession -ComputerName "NetworkSwitch08"

PS C:\\> Set-NetworkSwitchPortMode -CimSession $Session -TrunkMode -VlanIDs 2,17,22



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 sets NetworkSwitch08 to use trunk mode by using the $Session object. The command specifies IDs for three VLANs.





Example 2: Set a port to route mode



PS C:\\>Set-NetworkSwitchPortMode -CimSession $Session -IpAddress "10.14.1.1" -RouteMode -SubnetAddress "255.255.0.0"



This command sets the port to route mode. The command specifies its IP address and the subnet mask. The command includes a CimSession, similar to

the first example.







RELATED LINKS

Get-NetworkSwitchEthernetPort