mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
59 lines
1.6 KiB
PowerShell
59 lines
1.6 KiB
PowerShell
|
|
|
|||
|
|
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
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|