I often rebuild my lab and wanted to script something simple to recreate the VDS once I blast the lab. This is a very simple script I worked on to create my VDS environment and uplinks teaming.
Start-Transcript -Path C:\scripts\transcripts\create_vds_vmkDTCP-vDS-Switch.txt
#### Create Portgroups for vDS
Import-Module vmware.vimautomation.core
#Connect-VIServer DTCP-vc01.lab.local, DTCP-vc01.lab.local
Connect-VIServer uk3P-vc01.lab.local, ntcP-vc01.lab.local -User "rboadi@lab.local" -Password "StandUpIfYouHateTottenham"
$myDatacenter = Get-Datacenter -Name "LON-Datacenter"
New-VDSwitch -Name "DTCP-vDS-Switch" -Location $myDatacenter -NumUplinkPorts 6 -Version 6.0.0
# Set the VDS Name to variable
$vds = "DTCP-vDS-Switch"
$vdsname = get-vdswitch $vds
Get-vdswitch $vdsname | New-VDPortgroup -name 'Management_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup Management_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink3', 'dvUplink4', 'dvUplink5', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup Management_DTCP| Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink1', 'dvUplink2'
Get-vdswitch $vdsname | New-VDPortgroup -name 'vMotion_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup vMotion_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink5', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup vMotion_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink3', 'dvUplink4'
#### VM Networks
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Windows-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Windows-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Windows-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Linux-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Linux-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Linux-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Appliance-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Appliance-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Appliance-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-DMZ-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-DMZ-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-DMZ-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
#### iSCSI Networks
Get-vdswitch $vdsname | New-VDPortgroup -name 'iSCSI_1_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_1_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_1_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink7'
Get-vdswitch $vdsname | New-VDPortgroup -name 'iSCSI_2_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_2_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4', 'dvUplink5'
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_2_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink8'
# List the vLANS after creation
Write-Host "`nPortgroups created. Now confirming settings" -ForegroundColor Cyan
Get-VDSwitch $vdsname | Get-VDPortgroup | select name, numports, portbinding, vlanconfiguration
Stop-Transcript
Start-Transcript -Path C:\scripts\transcripts\create_vds_vmkDTCP-vDS-Switch.txt
#### Create Portgroups for vDS
Import-Module vmware.vimautomation.core
#Connect-VIServer DTCP-vc01.lab.local, DTCP-vc01.lab.local
Connect-VIServer uk3P-vc01.lab.local, ntcP-vc01.lab.local -User "rboadi@lab.local" -Password "StandUpIfYouHateTottenham"
$myDatacenter = Get-Datacenter -Name "LON-Datacenter"
New-VDSwitch -Name "DTCP-vDS-Switch" -Location $myDatacenter -NumUplinkPorts 6 -Version 6.0.0
# Set the VDS Name to variable
$vds = "DTCP-vDS-Switch"
$vdsname = get-vdswitch $vds
Get-vdswitch $vdsname | New-VDPortgroup -name 'Management_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup Management_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink3', 'dvUplink4', 'dvUplink5', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup Management_DTCP| Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink1', 'dvUplink2'
Get-vdswitch $vdsname | New-VDPortgroup -name 'vMotion_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup vMotion_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink5', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup vMotion_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink3', 'dvUplink4'
#### VM Networks
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Windows-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Windows-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Windows-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Linux-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Linux-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Linux-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-Appliance-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Appliance-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-Appliance-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
Get-vdswitch $vdsname | New-VDPortgroup -name 'DTCP-DMZ-vDS' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup DTCP-DMZ-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4'
get-vdswitch $vdsname | Get-VDPortgroup DTCP-DMZ-vDS | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink5', 'dvUplink6'
#### iSCSI Networks
Get-vdswitch $vdsname | New-VDPortgroup -name 'iSCSI_1_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_1_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4', 'dvUplink6'
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_1_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink7'
Get-vdswitch $vdsname | New-VDPortgroup -name 'iSCSI_2_DTCP' -NumPorts 6 -PortBinding Ephemeral
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_2_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -UnusedUplinkPort 'dvUplink1', 'dvUplink2', 'dvUplink3', 'dvUplink4', 'dvUplink5'
get-vdswitch $vdsname | Get-VDPortgroup iSCSI_2_DTCP | Get-VDUplinkTeamingPolicy | Set-VDUplinkTeamingPolicy -ActiveUplinkPort 'dvUplink8'
# List the vLANS after creation
Write-Host "`nPortgroups created. Now confirming settings" -ForegroundColor Cyan
Get-VDSwitch $vdsname | Get-VDPortgroup | select name, numports, portbinding, vlanconfiguration
Stop-Transcript
Hope you find this helpful. You can upgrade your VDS to version 6.5.0 then after. I chose version 6.0.0 as I have ESXi 6.0.0 in the lab.