Following are the PowerCLi script to create bulk dvSwitch port groups in vCenter 5.5/6.0/6.5/6.7
1. First create dvswitch in vCenter with any name as per your convenient. For example I created dvswitch with the name of "dvs_Internal" as showed below.
2. Copy the below script in notepad and pest it
3. Modify the vCenter name , dvswitch name where mentioned dvswitch name as "dvs_Internal". Also, change the port group name and VLAN number as per your requirement.
4. save the notepad as example dvPortGroupCreation.ps1
5. Now you can open the VMware vSphere PowerCLI and run the script.
6. it will show the progress of creation the dvport groups in the powercli screen.
7. once script completed you can login to vCenter server via webclient and you can see the new port groups.
Note: This script tested in test/dev/prod environment and working without any issue.
===========================================================================================================================
<#
.SYNOPSIS
Network Configuration
.DESCRIPTION
This script Create VM DVPort groups
.NOTES
Author: Nawal Singh
#>
#Connection to vCenter
$mycred = Get-Credential
Connect-VIServer "VCS01.domain.local" -Credential $mycred
Write-Progress -Activity "Creating DvPort Groups" -Status "Working" ;
#This section configures the dvport Groups
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_101" -NumPorts 128 -VLanId 101
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_102" -NumPorts 128 -VLanId 102
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_103" -NumPorts 128 -VLanId 103
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_104" -NumPorts 128 -VLanId 104
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_105" -NumPorts 128 -VLanId 105
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_106" -NumPorts 128 -VLanId 106
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_107" -NumPorts 128 -VLanId 107
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_108" -NumPorts 128 -VLanId 108
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_109" -NumPorts 128 -VLanId 109
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_110" -NumPorts 128 -VLanId 110
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_111" -NumPorts 128 -VLanId 111
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_112" -NumPorts 128 -VLanId 112
Get-VDSwitch -Name "dvs_Internal" | New-VDPortgroup -Name "dPG_VLAN_113" -NumPorts 128 -VLanId 113
Disconnect-VIServer -Server * -Force -Confirm:$false
===========================================================================================================================