VMware Cloud Community
JackChaka
Contributor
Contributor

PortGroup

Hello

I have  script which I run to create port groups and vlan id , the script reads an answer file for the list of portgroup to create, no problem always worked.

today, in the nswer file there was one blank line, the script managed to create a port group with No network LABEL AND NO VALN ID and I'm unable to delete it nothing will happen, if I try to add a network label and valn id I get the following message@: the object or item refereedn is not founf.

If I go to the ESX console and run vicfg-vswitch -list, I can this portgroup with blank label and 0 for the vlan id

any one can help me deleting this portgroup?

Regards

jack

0 Kudos
9 Replies
LucD
Leadership
Leadership

What happens when you do a "Get-VirtualPortgroup" ?

Is the faulty one included in the list ?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JackChaka
Contributor
Contributor

Hello

As you can see the second one is blanck

  GB2-RET-RC-PMS-DBS1           3013      0               vmnic5,vmnic4

                             0         0               vmnic5,vmnic4
 

0 Kudos
LucD
Leadership
Leadership

Ok, next step, can we use a Where-clause to extract the specific portgroup.

Do you only get the faulty one when you do either of these

Get-VirtualPortGroup | where {$_.Name -eq ""}

Get-VirtualPortGroup | where {$_.Name -eq $null}

Or perhaps with the VLANid

Get-VirtualPortGroup | where {$_.VlanId -eq 0}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JackChaka
Contributor
Contributor

Hello,

Thank you , yes I do see the port group, please see the result below

...                       key-vim.host.PortGroup-...     0

0 Kudos
JackChaka
Contributor
Contributor

Management Network        key-vim.host.PortGroup-Mana... 0

vMotion                             key-vim.host.PortGroup-vMotion 0

...                                     key-vim.host.PortGroup-...     0 this is the problem portgroup

0 Kudos
LucD
Leadership
Leadership

Then you can now pipe the faulty portgroup to the Remove-VirtualPortgroup cmdlet.

That way you do not have to specify a name


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JackChaka
Contributor
Contributor

what is the syntax to remove the port group?

0 Kudos
LucD
Leadership
Leadership

Something like this

Get-VirtualPortGroup | where {$_.VlanId -eq 0} |

Remove-VirtualPortGroup -Confirm:$false


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
JackChaka
Contributor
Contributor


Hello This will remove all port groups with vlan is =0

excuting the following command will delete portgroup=test on vSwitch1

Get-VirtualSwitch -Name vSwitch1 | Get-VirtualPortGroup -Name test | Remove-VirtualPortGroup

the portgoup I want to remove does not have Network label, so I can not put blank after -Name

Can you please advise

0 Kudos