2021-03-30 16:34:25 +02:00
|
|
|
|
<#
|
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:51
|
|
|
|
|
|
Created by: Claussen
|
|
|
|
|
|
Organization: NEOnet
|
|
|
|
|
|
Filename: New-NetboxIPAMAddress.ps1
|
|
|
|
|
|
===========================================================================
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
A description of the file.
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function New-NetboxIPAMAddress {
|
2021-03-30 16:34:25 +02:00
|
|
|
|
<#
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.SYNOPSIS
|
|
|
|
|
|
Create a new IP address to Netbox
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
Create a new IP address to Netbox with a status of Active by default.
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Address
|
|
|
|
|
|
IP address in CIDR notation: 192.168.1.1/24
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Status
|
|
|
|
|
|
Status of the IP. Defaults to Active
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Tenant
|
|
|
|
|
|
Tenant ID
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER VRF
|
|
|
|
|
|
VRF ID
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Role
|
|
|
|
|
|
Role such as anycast, loopback, etc... Defaults to nothing
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER NAT_Inside
|
|
|
|
|
|
ID of IP for NAT
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Custom_Fields
|
|
|
|
|
|
Custom field hash table. Will be validated by the API service
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Interface
|
|
|
|
|
|
ID of interface to apply IP
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Description
|
|
|
|
|
|
Description of IP address
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
.PARAMETER Dns_name
|
|
|
|
|
|
DNS Name of IP address (example : netbox.example.com)
|
|
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
.PARAMETER Force
|
|
|
|
|
|
Do not prompt for confirmation to create IP.
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.PARAMETER Raw
|
|
|
|
|
|
Return raw results from API service
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.EXAMPLE
|
|
|
|
|
|
PS C:\> Create-NetboxIPAMAddress
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.NOTES
|
|
|
|
|
|
Additional information about the function.
|
|
|
|
|
|
#>
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[CmdletBinding(ConfirmImpact = 'Low',
|
2021-03-30 16:34:25 +02:00
|
|
|
|
SupportsShouldProcess = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[OutputType([pscustomobject])]
|
|
|
|
|
|
param
|
|
|
|
|
|
(
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[Parameter(Mandatory = $true,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
ValueFromPipelineByPropertyName = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Address,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status = 'Active',
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
[int]$Tenant,
|
|
|
|
|
|
|
|
|
|
|
|
[int]$VRF,
|
|
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Role,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
[int]$NAT_Inside,
|
|
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[hashtable]$Custom_Fields,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
[int]$Interface,
|
|
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Description,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
[string]$Dns_name,
|
|
|
|
|
|
|
2021-03-25 16:52:08 -04:00
|
|
|
|
[switch]$Force,
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[switch]$Raw
|
|
|
|
|
|
)
|
2021-03-30 16:34:25 +02:00
|
|
|
|
|
|
|
|
|
|
process {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-addresses'))
|
|
|
|
|
|
$Method = 'POST'
|
|
|
|
|
|
|
|
|
|
|
|
# # Value validation
|
|
|
|
|
|
# $ModelDefinition = GetModelDefinitionFromURIPath -Segments $Segments -Method $Method
|
|
|
|
|
|
# $EnumProperties = GetModelEnumProperties -ModelDefinition $ModelDefinition
|
|
|
|
|
|
#
|
|
|
|
|
|
# foreach ($Property in $EnumProperties.Keys) {
|
|
|
|
|
|
# if ($PSBoundParameters.ContainsKey($Property)) {
|
|
|
|
|
|
# Write-Verbose "Validating property [$Property] with value [$($PSBoundParameters.$Property)]"
|
|
|
|
|
|
# $PSBoundParameters.$Property = ValidateValue -ModelDefinition $ModelDefinition -Property $Property -ProvidedValue $PSBoundParameters.$Property
|
|
|
|
|
|
# }
|
|
|
|
|
|
# }
|
|
|
|
|
|
#
|
|
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
|
|
|
|
|
|
|
|
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
|
|
|
|
|
|
|
|
|
|
if ($Force -or $PSCmdlet.ShouldProcess($Address, 'Create new IP address')) {
|
|
|
|
|
|
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
|
|
|
|
|
}
|
2021-03-25 16:52:08 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|