2021-07-23 22:06:42 +02:00
|
|
|
|
<#
|
2020-03-23 12:18:01 -04:00
|
|
|
|
.NOTES
|
|
|
|
|
|
===========================================================================
|
|
|
|
|
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
|
|
|
|
Created on: 3/23/2020 12:08
|
|
|
|
|
|
Created by: Claussen
|
|
|
|
|
|
Organization: NEOnet
|
|
|
|
|
|
Filename: New-NetboxDCIMDevice.ps1
|
|
|
|
|
|
===========================================================================
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
A description of the file.
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function New-NetboxDCIMDevice {
|
2021-07-23 22:06:42 +02:00
|
|
|
|
[CmdletBinding(ConfirmImpact = 'low',
|
|
|
|
|
|
SupportsShouldProcess = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[OutputType([pscustomobject])]
|
|
|
|
|
|
#region Parameters
|
|
|
|
|
|
param
|
|
|
|
|
|
(
|
|
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
|
[string]$Name,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
|
[object]$Device_Role,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
|
[object]$Device_Type,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
|
|
|
|
[uint16]$Site,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status = 'Active',
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Platform,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Tenant,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Cluster,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Rack,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Position,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Face,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Serial,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Asset_Tag,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Virtual_Chassis,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$VC_Priority,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$VC_Position,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Primary_IP4,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Primary_IP6,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Comments,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[hashtable]$Custom_Fields
|
|
|
|
|
|
)
|
|
|
|
|
|
#endregion Parameters
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
|
|
|
|
|
# if ($null -ne $Device_Role) {
|
|
|
|
|
|
# # Validate device role?
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
# if ($null -ne $Device_Type) {
|
|
|
|
|
|
# # Validate device type?
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
# if ($null -ne $Status) {
|
|
|
|
|
|
# $PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
# if ($null -ne $Face) {
|
|
|
|
|
|
# $PSBoundParameters.Face = ValidateDCIMChoice -ProvidedValue $Face -DeviceFace
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
|
|
|
|
|
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
|
|
|
|
|
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
|
|
|
|
|
|
}
|
2020-03-23 12:18:01 -04:00
|
|
|
|
}
|