mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
92 lines
2.7 KiB
PowerShell
92 lines
2.7 KiB
PowerShell
|
|
<#
|
|||
|
|
.NOTES
|
|||
|
|
===========================================================================
|
|||
|
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|||
|
|
Created on: 3/23/2020 12:11
|
|||
|
|
Created by: Claussen
|
|||
|
|
Organization: NEOnet
|
|||
|
|
Filename: Set-NetboxDCIMInterfaceConnection.ps1
|
|||
|
|
===========================================================================
|
|||
|
|
.DESCRIPTION
|
|||
|
|
A description of the file.
|
|||
|
|
#>
|
|||
|
|
|
|||
|
|
|
|||
|
|
function Set-NetboxDCIMInterfaceConnection {
|
|||
|
|
<#
|
|||
|
|
.SYNOPSIS
|
|||
|
|
Update an interface connection
|
|||
|
|
|
|||
|
|
.DESCRIPTION
|
|||
|
|
Update an interface connection
|
|||
|
|
|
|||
|
|
.PARAMETER Id
|
|||
|
|
A description of the Id parameter.
|
|||
|
|
|
|||
|
|
.PARAMETER Connection_Status
|
|||
|
|
A description of the Connection_Status parameter.
|
|||
|
|
|
|||
|
|
.PARAMETER Interface_A
|
|||
|
|
A description of the Interface_A parameter.
|
|||
|
|
|
|||
|
|
.PARAMETER Interface_B
|
|||
|
|
A description of the Interface_B parameter.
|
|||
|
|
|
|||
|
|
.PARAMETER Force
|
|||
|
|
A description of the Force parameter.
|
|||
|
|
|
|||
|
|
.EXAMPLE
|
|||
|
|
PS C:\> Set-NetboxDCIMInterfaceConnection -Id $value1
|
|||
|
|
|
|||
|
|
.NOTES
|
|||
|
|
Additional information about the function.
|
|||
|
|
#>
|
|||
|
|
|
|||
|
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
|||
|
|
SupportsShouldProcess = $true)]
|
|||
|
|
param
|
|||
|
|
(
|
|||
|
|
[Parameter(Mandatory = $true,
|
|||
|
|
ValueFromPipelineByPropertyName = $true)]
|
|||
|
|
[uint16[]]$Id,
|
|||
|
|
|
|||
|
|
[object]$Connection_Status,
|
|||
|
|
|
|||
|
|
[uint16]$Interface_A,
|
|||
|
|
|
|||
|
|
[uint16]$Interface_B,
|
|||
|
|
|
|||
|
|
[switch]$Force
|
|||
|
|
)
|
|||
|
|
|
|||
|
|
begin {
|
|||
|
|
if ($null -ne $Connection_Status) {
|
|||
|
|
$PSBoundParameters.Connection_Status = ValidateDCIMChoice -ProvidedValue $Connection_Status -InterfaceConnectionStatus
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if ((@($ID).Count -gt 1) -and ($Interface_A -or $Interface_B)) {
|
|||
|
|
throw "Cannot set multiple connections to the same interface"
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
process {
|
|||
|
|
foreach ($ConnectionID in $Id) {
|
|||
|
|
$CurrentConnection = Get-NetboxDCIMInterfaceConnection -Id $ConnectionID -ErrorAction Stop
|
|||
|
|
|
|||
|
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interface-connections', $CurrentConnection.Id))
|
|||
|
|
|
|||
|
|
if ($Force -or $pscmdlet.ShouldProcess("Connection ID $($CurrentConnection.Id)", "Set")) {
|
|||
|
|
|
|||
|
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|||
|
|
|
|||
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|||
|
|
|
|||
|
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
end {
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|