Fix New-NetboxVirtualMachine: Site is not mandatory, but site or cluster must be set

This commit is contained in:
Pascal Liehne 2024-10-02 22:27:13 +02:00
parent 3abf2264d9
commit e2697e7add
4 changed files with 6 additions and 8 deletions

View file

@ -8,7 +8,6 @@ function New-NetboxVirtualMachine {
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[uint64]$Site,
[uint64]$Cluster,
@ -45,8 +44,8 @@ function New-NetboxVirtualMachine {
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
if ($PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "You must specify a site ID with a cluster ID"
if (-not $PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "A virtual machine must be assigned to a site and/or cluster."
}
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))

View file

@ -3,7 +3,7 @@
#
# Generated by: Ben Claussen
#
# Generated on: 01/09/2024
# Generated on: 10/2/2024
#
@{

View file

@ -3,7 +3,7 @@
#
# Generated by: Ben Claussen
#
# Generated on: 01/09/2024
# Generated on: 10/2/2024
#
@{

View file

@ -4502,7 +4502,6 @@ function New-NetboxVirtualMachine {
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[uint64]$Site,
[uint64]$Cluster,
@ -4539,8 +4538,8 @@ function New-NetboxVirtualMachine {
#$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
if ($PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "You must specify a site ID with a cluster ID"
if (-not $PSBoundParameters.ContainsKey('Cluster') -and (-not $PSBoundParameters.ContainsKey('Site'))) {
throw "A virtual machine must be assigned to a site and/or cluster."
}
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))