NetboxPS/Functions/DCIM/Devices/Set-NetboxDCIMDevice.ps1

96 lines
2.2 KiB
PowerShell
Raw Normal View History

<#
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: Set-NetboxDCIMDevice.ps1
===========================================================================
.DESCRIPTION
A description of the file.
#>
function Set-NetboxDCIMDevice {
[CmdletBinding(SupportsShouldProcess = $true)]
param
(
[Parameter(Mandatory = $true,
ValueFromPipelineByPropertyName = $true)]
[uint16[]]$Id,
2020-03-23 12:18:01 -04:00
[string]$Name,
2020-03-23 12:18:01 -04:00
[object]$Device_Role,
2020-03-23 12:18:01 -04:00
[object]$Device_Type,
2020-03-23 12:18:01 -04:00
[uint16]$Site,
2020-03-23 12:18:01 -04:00
[object]$Status,
2020-03-23 12:18:01 -04:00
[uint16]$Platform,
2020-03-23 12:18:01 -04:00
[uint16]$Tenant,
2020-03-23 12:18:01 -04:00
[uint16]$Cluster,
2020-03-23 12:18:01 -04:00
[uint16]$Rack,
2020-03-23 12:18:01 -04:00
[uint16]$Position,
2020-03-23 12:18:01 -04:00
[object]$Face,
2020-03-23 12:18:01 -04:00
[string]$Serial,
2020-03-23 12:18:01 -04:00
[string]$Asset_Tag,
2020-03-23 12:18:01 -04:00
[uint16]$Virtual_Chassis,
2020-03-23 12:18:01 -04:00
[uint16]$VC_Priority,
2020-03-23 12:18:01 -04:00
[uint16]$VC_Position,
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP4,
2020-03-23 12:18:01 -04:00
[uint16]$Primary_IP6,
2020-03-23 12:18:01 -04:00
[string]$Comments,
2020-03-23 12:18:01 -04:00
[hashtable]$Custom_Fields,
2020-03-23 12:18:01 -04:00
[switch]$Force
)
2020-03-23 12:18:01 -04:00
begin {
# 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
}
2020-03-23 12:18:01 -04:00
process {
foreach ($DeviceID in $Id) {
$CurrentDevice = Get-NetboxDCIMDevice -Id $DeviceID -ErrorAction Stop
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))
2020-03-23 12:18:01 -04:00
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
2020-03-23 12:18:01 -04:00
$URI = BuildNewURI -Segments $URIComponents.Segments
2020-03-23 12:18:01 -04:00
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
}
2020-03-23 12:18:01 -04:00
end {
2020-03-23 12:18:01 -04:00
}
}