NetboxPS/Functions/IPAM/VLAN/New-NetboxIPAMVLAN.ps1

79 lines
1.9 KiB
PowerShell
Raw Normal View History

function New-NetboxIPAMVLAN {
2020-03-23 12:18:01 -04:00
<#
.SYNOPSIS
Create a new VLAN
2020-03-23 12:18:01 -04:00
.DESCRIPTION
Create a new VLAN in Netbox with a status of Active by default.
2020-03-23 12:18:01 -04:00
.PARAMETER VID
The VLAN ID.
.PARAMETER Name
The name of the VLAN.
2020-03-23 12:18:01 -04:00
.PARAMETER Status
Status of the VLAN. Defaults to Active
2020-03-23 12:18:01 -04:00
.PARAMETER Tenant
Tenant ID
.PARAMETER Role
Role such as anycast, loopback, etc... Defaults to nothing
.PARAMETER Description
Description of IP address
2020-03-23 12:18:01 -04:00
.PARAMETER Custom_Fields
Custom field hash table. Will be validated by the API service
.PARAMETER Raw
Return raw results from API service
.PARAMETER Address
IP address in CIDR notation: 192.168.1.1/24
2020-03-23 12:18:01 -04:00
.EXAMPLE
PS C:\> Create-NetboxIPAMAddress
.NOTES
Additional information about the function.
#>
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true)]
[uint16]$VID,
[Parameter(Mandatory = $true)]
[string]$Name,
2020-03-23 12:18:01 -04:00
[object]$Status = 'Active',
[uint16]$Tenant,
[object]$Role,
[string]$Description,
2020-03-23 12:18:01 -04:00
[hashtable]$Custom_Fields,
[switch]$Raw
)
# $PSBoundParameters.Status = ValidateIPAMChoice -ProvidedValue $Status -VLANStatus
#
# if ($null -ne $Role) {
# $PSBoundParameters.Role = ValidateIPAMChoice -ProvidedValue $Role -IPAddressRole
# }
2020-03-23 12:18:01 -04:00
$segments = [System.Collections.ArrayList]::new(@('ipam', 'vlans'))
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $segments -ParametersDictionary $PSBoundParameters
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
}