Removing IP Pools Using PowerCLI

I recently had the need to create many IP Pools (also known as Network Protocol Profiles) for some projects I have been working on. I was able to flip through my copy of  “VMware vSphere PowerCLI Reference” and leverage a script on creating IP Pools. Not only did I need a way to create IP Pools using PowerCLI, I also needed a way to remove them as well. A quick Google search didn’t return any results on the topic so I went ahead and created a simple function that allows the user to remove them.

As you can see I currently have two pools in my virtual Data Center “SDT”


The function requires the user to know the name of the virtual Data Center that the IP Pool is located in, and the name of the IP Pool. After the function is added into the PowerCLI session, it can be called by typing ‘Remove-IPPool <vDC Name> <IP Pool Name>’


You will notice the task will appear in the “Recent Tasks” window once the function has run. If you are looking at the Network Protocol Profiles you will need to refresh the window to see the changes visually.


The function is found below. You may also CLICK HERE to download the script in a .zip

Function Remove-IPPool {
This function will remove IP-Pools from vCenter
This function will remove IP-Pools from vCenter based on the inputs provided
Assuming my datacenter was ‘westwing’ and my IPPool was ‘IPPool1’
remove-ippool westwing IPPool1
Author: Brian Graf
Role: Technical Marketing Engineer, VMware
Last Edited: 05/01/2014

Param (
[Parameter(ValueFromPipeline = $true, valuefrompipelinebypropertyname = $true)]
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]

Process {
$dc = (Get-datacenter $Datacenter)
$dcenter = New-Object VMware.Vim.ManagedObjectReference
$dcenter.type = $dc.ExtensionData.moref.type
$dcenter.Value = $dc.ExtensionData.moref.value

    $IPPoolManager = Get-View -Id ‘IpPoolManager’
$SelectedPool = ($IPPoolManager.QueryIpPools($dc.ID) | Where-Object { $_.Name -like $PoolName })

    $IPPool = Get-View -Id ‘IpPoolManager-IpPoolManager’
$IPPool.DestroyIpPool($dcenter, $, $true)




One comment has been added so far

Leave a Reply

Your email address will not be published. Required fields are marked *