mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-13 18:02:29 +00:00
* Fix trailing white space using Invoke-ScriptAnalyzer -Fix -Path . -Recurse * add settings.json for configure Visual Code (Formatter) * PSSA: Fix Command accepts pipeline input but has not defined a process block * PSSA: Fix PSUseDeclaredVarsMoreThanAssignments The variable 'I_B' is assigned but never used The variable 'I_A' is assigned but never used * PSSA: Fix PSUseShouldProcessForStateChangingFunctions Function New-/Set-... has verb that could change system state. Therefore, the function has to support 'ShouldProcess'
72 lines
1.9 KiB
PowerShell
72 lines
1.9 KiB
PowerShell
<#
|
|
.NOTES
|
|
===========================================================================
|
|
Created with: SAPIEN Technologies, Inc., PowerShell Studio 2020 v5.7.172
|
|
Created on: 3/19/2020 12:44
|
|
Created by: Claussen
|
|
Organization: NEOnet
|
|
Filename: New-NetboxVirtualMachine.ps1
|
|
===========================================================================
|
|
.DESCRIPTION
|
|
A description of the file.
|
|
#>
|
|
|
|
|
|
function New-NetboxVirtualMachine {
|
|
[CmdletBinding(ConfirmImpact = 'low',
|
|
SupportsShouldProcess = $true)]
|
|
[OutputType([pscustomobject])]
|
|
param
|
|
(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$Name,
|
|
|
|
[Parameter(Mandatory = $true)]
|
|
[uint16]$Cluster,
|
|
|
|
[uint16]$Tenant,
|
|
|
|
[object]$Status = 'Active',
|
|
|
|
[uint16]$Role,
|
|
|
|
[uint16]$Platform,
|
|
|
|
[uint16]$vCPUs,
|
|
|
|
[uint16]$Memory,
|
|
|
|
[uint16]$Disk,
|
|
|
|
[uint16]$Primary_IP4,
|
|
|
|
[uint16]$Primary_IP6,
|
|
|
|
[hashtable]$Custom_Fields,
|
|
|
|
[string]$Comments
|
|
)
|
|
|
|
# $ModelDefinition = $script:NetboxConfig.APIDefinition.definitions.WritableVirtualMachineWithConfigContext
|
|
|
|
# # Validate the status against the APIDefinition
|
|
# if ($ModelDefinition.properties.status.enum -inotcontains $Status) {
|
|
# throw ("Invalid value [] for Status. Must be one of []" -f $Status, ($ModelDefinition.properties.status.enum -join ', '))
|
|
# }
|
|
|
|
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
|
|
|
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
|
|
|
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
|
|
|
$URI = BuildNewURI -Segments $URIComponents.Segments
|
|
|
|
if ($PSCmdlet.ShouldProcess($name, 'Create new Virtual Machine')) {
|
|
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|