diff --git a/Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1 b/Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1 new file mode 100644 index 0000000..cb1892f --- /dev/null +++ b/Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1 @@ -0,0 +1,58 @@ + +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 + } + } + } +}