NetboxPS/Functions/IPAM/Address/Remove-NetboxIPAMAddress.ps1
Alexis La Goutte 2595c58eaa
(WIP) Enhance IPAM Address (#4)
* Address(IPAM): Fix trailing whitespace (with Visual Code Formater)

* Address(IPAM): Fix PSSA about Command accepts pipeline input but not defined a process block

* Address(IPAM): Add dns_name parameter to Add and Set

* Address(IPAM): all integer are [int] (not uint16)
2021-03-30 10:34:25 -04:00

59 lines
No EOL
1.5 KiB
PowerShell

<#
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 11:52
Created by: Claussen
Organization: NEOnet
Filename: Remove-NetboxIPAMAddress.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Remove-NetboxIPAMAddress {
<#
.SYNOPSIS
Remove an IP address from Netbox
.DESCRIPTION
Removes/deletes an IP address from Netbox by ID and optional other filters
.PARAMETER Id
Database ID of the IP address object.
.PARAMETER Force
Do not confirm.
.EXAMPLE
PS C:\> Remove-NetboxIPAMAddress -Id $value1
.NOTES
Additional information about the function.
#>
[CmdletBinding(ConfirmImpact = 'High',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[int[]]$Id,
[switch]$Force
)
process {
foreach ($IPId in $Id) {
$CurrentIP = Get-NetboxIPAMAddress -Id $IPId -ErrorAction Stop
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses', $IPId))
if ($Force -or $pscmdlet.ShouldProcess($CurrentIP.Address, "Delete")) {
$URI = BuildNewURI -Segments $Segments
InvokeNetboxRequest -URI $URI -Method DELETE
}
}
}
}