Public/Remove-iRule.ps1
Function Remove-iRule { <# .SYNOPSIS Remove the specified irule(s). Confirmation is needed. #> [cmdletBinding( SupportsShouldProcess=$true, ConfirmImpact='High')] param ( $F5Session=$Script:F5Session, [Alias('iRule')] [Parameter(Mandatory=$true,ParameterSetName='InputObject',ValueFromPipeline=$true)] [PSObject[]]$InputObject, [Alias('iRuleName')] [Parameter(Mandatory=$true,ParameterSetName='Name',ValueFromPipeline=$true,ValueFromPipelineByPropertyName=$true)] [string[]]$Name, [Parameter(Mandatory=$false,ValueFromPipelineByPropertyName=$true)] [string]$Partition ) begin { #Test that the F5 session is in a valid format Test-F5Session($F5Session) Write-Verbose "NB: iRule names are case-specific." } process { switch($PSCmdLet.ParameterSetName) { InputObject { foreach($item in $InputObject) { if ($pscmdlet.ShouldProcess($item.fullPath)){ $URI = $F5Session.GetLink($item.selfLink) Invoke-F5RestMethod -Method DELETE -Uri $URI -F5Session $F5Session } } } Name { $Name | Get-iRule -F5Session $F5Session -Partition $Partition | Remove-iRule -F5session $F5Session } } } } |