Hi,
I saw the discussion about the AddPortGroup function for adding port groups to a virtual switch, but haven't seen anything about removing a port group from a virtual switch. Is there any way of doing this with the vi toolkit?
Thanks!
Eric K. Miller, Genesis Hosting Solutions, LLC
- Lease part of our ESX cluster!
Sure, the following script removes a portgroup from all ESX servers.
If you want to remove the portgroup from a specific ESX server you can add for example a -Name parameter to the Get-VMHost cmdlet.
$MyPortGroupName = "Internal" Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{ $_.RemovePortGroup($MyPortGroupName) }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Sure, the following script removes a portgroup from all ESX servers.
If you want to remove the portgroup from a specific ESX server you can add for example a -Name parameter to the Get-VMHost cmdlet.
$MyPortGroupName = "Internal" Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{ $_.RemovePortGroup($MyPortGroupName) }
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
You could use the attached script with PowerScripter with right click on a host within VI client and chosing the menu item of the script. This script opens a Select Box for deleting portgroups.You can select a host, multiple hosts, a cluster or a datacenter an run the script against for deleting the portgroups anywhere.
PowerScripter - customize VI client or VirtualCenter
Just wanted to update the information about PowerScripter - it is now being developed by Devfarm Software and has been rebranded as PowerVI. You can get more information at: http://powerwf.com/products/powerscripter.aspx
LucD
Much water have flown down the bridge since this 2008 post so thought to recheck
I intend to use below code to Mass delete DVS port groups from a VDS starting with "vxw" and have adapted the below code . V center version is 6.5 .
$MyPortGroupName = "Internal"
Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{
$_.RemovePortGroup($MyPortGroupName)
}
to
Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{
$_.RemovePortGroup($MyPortGroupName)
}
I was wondering if above will work as i m trying to use wild character * in Above example. I was trying to use these wild characters in Get-virtualswitch command and they seems to be working on their own good will .
Kinldy advice if there is a alternate way to delete port groups enmass. All are VM port groups.
That will not work, the RemovePortgroup method does not support name masking.
But you could do something like this
Get-VMHost | %{Get-View (Get-View $_.ID).configmanager.networkSystem} | %{
$_.RemovePortGroup($vdp)
}
}
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference