I have the following script that allows the user to select nodes, then ask what VLAN on that node to apply to one of two different types of interfaces. It works well as long as there is just ONE interface selected for each "role" (Test Laptop / Test Set).
Is there a way to "foreach" type loop application of interface commands if more than one is selected?
/*
.CHANGE_TEMPLATE_DESCRIPTION
Change Interface Configuration on Cisco IOS devices to comply with BITI TRD and STIG
.CHANGE_TEMPLATE_TAGS
Cisco
.PLATFORM_DESCRIPTION
Cisco IOS
.PARAMETER_LABEL @ContextNode
NCM Node
.PARAMETER_DESCRIPTION @ContextNode
The node the template will operate on. All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.
.PARAMETER_LABEL @VlanToAssign
VLAN to assign
.PARAMETER_DESCRIPTION @VlanToAssign
Select the VLAN you would like to assign.
.PARAMETER_LABEL @LaptopPort
Port on the switch where the test laptop will be connected
.PARAMETER_DESCRIPTION @LaptopPort
Port on the switch where the test laptop will be connected
.PARAMETER_LABEL @GeneratorPort
Port on the switch where the traffic generator will be connected
.PARAMETER_DESCRIPTION @GeneratorPort
Port on the switch where the traffic generator will be connected
*/
script ChangeInterfaceBITICiscoIOS (
NCM.Nodes @ContextNode,
NCM.VLANs @VlanToAssign,
NCM.Interfaces[] @LaptopPort,
NCM.Interfaces[] @GeneratorPort)
{
// Enter config terminal mode
CLI
{
configure terminal
interface @LaptopPort.InterfaceDescription
description GDIT_Test_Port
switchport access vlan @VlanToAssign.VLANID
ip arp inspection trust
no shut
int @GeneratorPort.InterfaceDescription
description GDIT_Test_Port
switchport access vlan @VlanToAssign.VLANID
ip arp inspection trust
no storm-control unicast level
no shut
}
//Exit Config mode
CLI {end}
}