Files
PowerCLI-Example-Scripts/Scripts/Remove-IPPool.ps1
Kyle Ruddy cb35edea02 Reorganizational Update
Reorganizing of the repo for better, more streamlined access
2016-07-07 21:04:40 -04:00

39 lines
1.1 KiB
PowerShell

Function Remove-IPPool {
<#
.Synopsis
This function will remove IP-Pools from vCenter
.Description
This function will remove IP-Pools from vCenter based on the inputs provided
.Example
Assuming my datacenter was 'westwing' and my IPPool was 'IPPool1'
remove-ippool westwing IPPool1
.Notes
Author: Brian Graf
Role: Technical Marketing Engineer, VMware
Last Edited: 05/01/2014
#>
[cmdletbinding()]
Param (
[Parameter(ValueFromPipeline = $true, valuefrompipelinebypropertyname = $true)]
[String]$Datacenter,
[Parameter(ValueFromPipeline = $true, ValueFromPipelineByPropertyName = $true)]
[String]$PoolName
)
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, $SelectedPool.id, $true)
}
}