mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 09:52:29 +00:00
Add Set-NetboxIPAMAddressRange
This commit is contained in:
parent
bb0dfc0aa4
commit
9e00636fbe
1 changed files with 58 additions and 0 deletions
58
Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1
Normal file
58
Functions/IPAM/Range/Set-NetboxIPAMAddressRange.ps1
Normal file
|
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue