View Only
  • 1.  Mulitple DVPort | Multiple VLANs

    Posted Sep 10, 2015 12:01 AM

    Hey all,

    Have a question on how to script up implementing multiple DVPort Groups with different VLAN requirements. I've got a little bit of an idea but my lack of Powershell skill is holding me back. So I'm not sure how to implement the ForEach with multiple variables

    Thanks all

    $DVPortGroupNames = @("PortGroup#1","PortGroup#2","PortGroup#3","PortGroup#4).....and so on

    $VLANIDs = @("VLANID1","VLANID2","VLANID3","VLANID4") and so on......

    $VDPortGroupNotes = xxxxxxxxxxxxxxxxxxxx

    ForEach ($DVPortGroupName in $DVPortGroupNames) {

    Get-VDSwitch -Name switchname | New-VDPortGroup -Name $DVPortGroupName -Notes $VDPortGroupNotes -VLANId $VLANIDs


  • 2.  RE: Mulitple DVPort | Multiple VLANs

    Posted Sep 10, 2015 03:28 AM

    If you're just looking for a "quick and dirty" with the port group info hard coded in the script then you could do something like this using nested collections (I've just picked random VLAN IDs)

    # First element [0] is the name of the port group
    # Second element [1] is the VLANID
    # Third element [2] is the description of the port group
    $DVPGs = @( ("PG1", 1, "Production servers"), ("PG2", 27, "DMZ servers"), ("PG3", 132, "Management"))
    $vdSwitch = Get-VDSwitch -Name "nameoftheswitch"
    ForEach ($DVPG in $DVPGS) {
        $vdSwitch | New-VDPortGroup -Name $DVPG[0] -VLANID $DVPG[1] -Notes $DVPG[2]

    If you have a bunch of these to do then it may be easier to create a CSV file containing the information then grab the data from the CSV file in your script rather than hard coding the values in the script itself