This is a quick entry so that I can note down a small snippet of code for next time when I run into this one. Recently I have worked with Microsoft System Centre Virtual Machine Manager (SCVMM) 2012 SP1 and found that after creating a managed IP Address Pool that when needing to remove the Pool I had to first remove the allocated IP’s that VMM had linked to hosts under management. Rather than manually removing each one I was able to pipe the command-line to do a bulk removal of the entire subnet.
Here is the example snippet that does this:
PS C:\Windows\system32> $IPPool = Get-SCStaticIPAddressPool -IPv4 -Subnet "10.0.0.0/8" PS C:\Windows\system32> $IP = Get-SCIPAddress -StaticIPAddressPool $IPPool PS C:\Windows\system32> $IP | Revoke-SCIPAddress