NetboxPS/Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1

59 lines
1.4 KiB
PowerShell
Raw Normal View History

2023-11-07 10:16:45 -05:00

function Set-NetboxIPAMAddressRange {
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint64[]]$Id,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[string]$Start_Address,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[string]$End_Address,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[object]$Status,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[uint64]$Tenant,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[uint64]$VRF,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[object]$Role,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[hashtable]$Custom_Fields,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[string]$Description,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[string]$Comments,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[object[]]$Tags,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[switch]$Mark_Utilized,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[switch]$Force,
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
[switch]$Raw
)
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
begin {
$Method = 'PATCH'
}
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
process {
foreach ($RangeID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $RangeID))
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
Write-Verbose "Obtaining IP range from ID $RangeID"
$CurrentRange = Get-NetboxIPAMAddressRange -Id $RangeID -ErrorAction Stop
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
if ($Force -or $PSCmdlet.ShouldProcess("$($CurrentRange.Start_Address) - $($CurrentRange.End_Address)", 'Set')) {
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2023-11-07 10:20:23 -05:00
2023-11-07 10:16:45 -05:00
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
}
}
}
}