2022-12-06 13:34:52 -05:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
function Set-NetboxDCIMDevice {
|
|
|
|
|
|
[CmdletBinding(SupportsShouldProcess = $true)]
|
|
|
|
|
|
param
|
|
|
|
|
|
(
|
|
|
|
|
|
[Parameter(Mandatory = $true,
|
|
|
|
|
|
ValueFromPipelineByPropertyName = $true)]
|
|
|
|
|
|
[uint16[]]$Id,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[string]$Name,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Device_Role,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Device_Type,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Site,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[object]$Status,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Platform,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Tenant,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Cluster,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$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
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Virtual_Chassis,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$VC_Priority,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$VC_Position,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$Primary_IP4,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2023-07-28 15:38:16 -04:00
|
|
|
|
[uint64]$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,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[switch]$Force
|
|
|
|
|
|
)
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
begin {
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
}
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
process {
|
|
|
|
|
|
foreach ($DeviceID in $Id) {
|
|
|
|
|
|
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
if ($Force -or $pscmdlet.ShouldProcess("$($CurrentDevice.Name)", "Set")) {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices', $CurrentDevice.Id))
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
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
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
end {
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|