- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am getting the following error when adding new port groups to an existing vDS.
New-VDPortgroup : Operation is not valid due to the current state of the object. At P:\VMware\Create vDS PortGroups\Create vDS PortGroups - New v2.ps1:30 char:25 + ... t-VDSwitch $vDS | New-VDPortgroup -Name $vDS_PGName -VlanId $vDS_VLAN + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [New-VDPortgroup], InvalidOperationException + FullyQualifiedErrorId : System.InvalidOperationException,VMware.VimAutomation.Vds.Commands.Cmdlets.NewVDPortgroup |
The new port groups ARE added despite the error.
The Powershell script I am using is as follows:
# vCenter Credentials
$VIServer = "mc-vcsa-v-301a.momusconsulting.com"
$VIUsername = 'administrator@vsphere.local'
$VIPassword = 'Pa55word5!'
# The vDS to add the PortGroups to
$vDS = "vDS1_SiteA-65"
# vCenter vDS Port Group and VLAN - "{PGName}" = "{VLAN ID}"
$vDS_VLAN_PGNAME = @{
"VLAN050_Prod-VMs-A" = "50"
"VLAN101_Management-A" = "101"
"VLAN102_vMotion-A" = "102"
"VLAN103_vSAN-A" = "103"
"VLAN104_iSCSI1-A" = "104"
"VLAN105_iSCSI2-A" = "105"
"VLAN106_Replication-A" = "106"
"VLAN107_NFS-A" = "107"
}
Clear
vCenter = Connect-VIServer $VIServer -User $VIUsername -Password $VIPassword -WarningAction SilentlyContinue
$vDS_VLAN_PGNAME.GetEnumerator() | Sort-Object -Property Name | Foreach-Object {
$vDS_PGName = $_.Name
$vDS_VLAN = $_.Value
Get-VDSwitch $vDS | New-VDPortgroup -Name $vDS_PGName -VlanId $vDS_VLAN
}
A bit confused. Would appreciate it if anyone can shine a light on why this is erroring.
Thanks,
M