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

59 lines
1.6 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,
[string]$Start_Address,
[string]$End_Address,
[object]$Status,
[uint64]$Tenant,
[uint64]$VRF,
[object]$Role,
[hashtable]$Custom_Fields,
[string]$Description,
[string]$Comments,
[object[]]$Tags,
[switch]$Mark_Utilized,
[switch]$Force,
[switch]$Raw
)
begin {
$Method = 'PATCH'
}
process {
foreach ($RangeID in $Id) {
$Segments = [System.Collections.ArrayList]::new(@('ipam', 'ip-ranges', $RangeID))
Write-Verbose "Obtaining IP range from ID $RangeID"
$CurrentRange = Get-NetboxIPAMAddressRange -Id $RangeID -ErrorAction Stop
if ($Force -or $PSCmdlet.ShouldProcess("$($CurrentRange.Start_Address) - $($CurrentRange.End_Address)", 'Set')) {
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
$URI = BuildNewURI -Segments $URIComponents.Segments
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method $Method
}
}
}
}