NetboxPS/Functions/DCIM/RearPorts/Add-NetboxDCIMRearPort.ps1

59 lines
1.4 KiB
PowerShell
Raw Normal View History

function Add-NetboxDCIMRearPort {
2023-03-13 13:59:54 +00:00
[CmdletBinding()]
[OutputType([pscustomobject])]
param
(
[Parameter(Mandatory = $true)]
[uint16]$Device,
[uint16]$Module,
[Parameter(Mandatory = $true)]
[string]$Name,
[string]$Label,
[Parameter(Mandatory = $true)]
[string]$Type,
[ValidatePattern('^[0-9a-f]{6}$')]
2023-03-13 13:59:54 +00:00
[string]$Color,
2023-03-13 17:14:54 +00:00
[uint16]$Positions = 1,
2023-03-13 13:59:54 +00:00
[string]$Description,
2023-03-14 10:40:28 +00:00
[bool]$Mark_Connected,
[uint16[]]$Tags,
[string[]]$Tags_Slug
2023-03-13 13:59:54 +00:00
)
begin {
if (-not [System.String]::IsNullOrWhiteSpace($Tags_Slug)) {
if ([System.String]::IsNullOrWhiteSpace($Tags)) {
$PSBoundParameters.Tags = @()
}
foreach ($CurrentTagSlug in $Tags_Slug) {
$CurrentTagID = (Get-NetboxTag -slug $CurrentTagSlug -ErrorAction Stop).Id
$PSBoundParameters.Tags += $CurrentTagID
}
}
}
process {
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'rear-ports'))
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Tags_Slug'
$URI = BuildNewURI -Segments $URIComponents.Segments
2023-03-13 13:59:54 +00:00
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
2023-03-13 13:59:54 +00:00
end {
2023-03-13 13:59:54 +00:00
}
2023-03-13 13:59:54 +00:00
}