NetboxPS/Functions/IPAM/Address/Get-NetboxIPAMAvailableIP.ps1

73 lines
2.1 KiB
PowerShell
Raw Normal View History

<#
2020-03-23 12:18:01 -04:00
.NOTES
===========================================================================
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
Created on: 3/19/2020 11:50
Created by: Claussen
Organization: NEOnet
Filename: Get-NetboxIPAMAvailableIP.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Get-NetboxIPAMAvailableIP {
<#
2020-03-23 12:18:01 -04:00
.SYNOPSIS
A convenience method for returning available IP addresses within a prefix
2020-03-23 12:18:01 -04:00
.DESCRIPTION
By default, the number of IPs returned will be equivalent to PAGINATE_COUNT. An arbitrary limit
(up to MAX_PAGE_SIZE, if set) may be passed, however results will not be paginated
2020-03-23 12:18:01 -04:00
.PARAMETER Prefix_ID
A description of the Prefix_ID parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Limit
A description of the Limit parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER Raw
A description of the Raw parameter.
2020-03-23 12:18:01 -04:00
.PARAMETER NumberOfIPs
A description of the NumberOfIPs parameter.
2020-03-23 12:18:01 -04:00
.EXAMPLE
Get-NetboxIPAMAvailableIP -Prefix_ID (Get-NetboxIPAMPrefix -Prefix 192.0.2.0/24).id
Get (Next) Available IP on the Prefix 192.0.2.0/24
.EXAMPLE
Get-NetboxIPAMAvailableIP -Prefix_ID 2 -NumberOfIPs 3
Get 3 (Next) Available IP on the Prefix 192.0.2.0/24
2020-03-23 12:18:01 -04:00
.NOTES
Additional information about the function.
#>
2020-03-23 12:18:01 -04:00
[CmdletBinding()]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
2020-03-23 12:18:01 -04:00
[Alias('Id')]
[int]$Prefix_ID,
2020-03-23 12:18:01 -04:00
[Alias('NumberOfIPs')]
[int]$Limit,
2020-03-23 12:18:01 -04:00
[switch]$Raw
)
process {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'prefixes', $Prefix_ID, 'available-ips'))
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'prefix_id'
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
InvokeNetboxRequest -URI $uri -Raw:$Raw
}
2020-03-23 12:18:01 -04:00
}