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/19/2020 12:45
|
|
|
|
|
|
Created by: Claussen
|
|
|
|
|
|
Organization: NEOnet
|
|
|
|
|
|
Filename: Set-NetboxVirtualMachine.ps1
|
|
|
|
|
|
===========================================================================
|
|
|
|
|
|
.DESCRIPTION
|
|
|
|
|
|
A description of the file.
|
|
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function Set-NetboxVirtualMachine {
|
|
|
|
|
|
[CmdletBinding(ConfirmImpact = 'Medium',
|
2021-07-23 22:06:42 +02:00
|
|
|
|
SupportsShouldProcess = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
param
|
|
|
|
|
|
(
|
|
|
|
|
|
[Parameter(Mandatory = $true,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
ValueFromPipelineByPropertyName = $true)]
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[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
|
|
|
|
[uint16]$Role,
|
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
|
|
|
|
[object]$Status,
|
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]$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
|
|
|
|
[byte]$VCPUs,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Memory,
|
2021-07-23 22:06:42 +02:00
|
|
|
|
|
2020-03-23 12:18:01 -04:00
|
|
|
|
[uint16]$Disk,
|
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
|
|
|
|
[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
|
|
|
|
|
|
|
|
|
|
# if ($null -ne $Status) {
|
|
|
|
|
|
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
|
|
|
|
|
# }
|
|
|
|
|
|
|
|
|
|
|
|
process {
|
|
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
|
|
|
|
|
|
|
|
|
|
|
Write-Verbose "Obtaining VM from ID $Id"
|
|
|
|
|
|
|
|
|
|
|
|
#$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
|
|
|
|
|
|
|
|
|
|
|
|
Write-Verbose "Finished obtaining VM"
|
|
|
|
|
|
|
|
|
|
|
|
if ($Force -or $pscmdlet.ShouldProcess($ID, "Set properties on VM ID")) {
|
|
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Id', 'Force'
|
|
|
|
|
|
|
|
|
|
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
|
|
|
|
|
|
|
|
|
|
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
|
|
|
|
|
}
|
2020-03-23 12:18:01 -04:00
|
|
|
|
}
|
|
|
|
|
|
}
|