mirror of
https://github.com/benclaussen/NetboxPS.git
synced 2025-12-16 03:05:47 +00:00
PSSA: Fix Command accepts pipeline input but has not defined a process block
This commit is contained in:
parent
76b891542e
commit
0217808bfc
8 changed files with 104 additions and 88 deletions
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxCircuit {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets one or more circuits
|
||||
|
||||
|
|
@ -105,27 +105,29 @@ function Get-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($i in $ID) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits', $i))
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($i in $ID) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits', $i))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
default {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
default {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -15,12 +15,12 @@
|
|||
|
||||
function New-NetboxCircuit {
|
||||
[CmdletBinding(ConfirmImpact = 'Low',
|
||||
SupportsShouldProcess = $true)]
|
||||
SupportsShouldProcess = $true)]
|
||||
[OutputType([pscustomobject])]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[string]$CID,
|
||||
|
||||
[Parameter(Mandatory = $true)]
|
||||
|
|
@ -54,14 +54,16 @@ function New-NetboxCircuit {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
$Method = 'POST'
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('circuits', 'circuits'))
|
||||
$Method = 'POST'
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
if ($Force -or $PSCmdlet.ShouldProcess($CID, 'Create new circuit')) {
|
||||
InvokeNetboxRequest -URI $URI -Method $Method -Body $URIComponents.Parameters -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -85,15 +85,17 @@ function Get-NetboxDCIMDevice {
|
|||
|
||||
#endregion Parameters
|
||||
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateDCIMChoice -ProvidedValue $Status -DeviceStatus
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'devices'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName 'Raw'
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
|
|
@ -47,15 +47,17 @@ function Get-NetboxDCIMInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
if ($null -ne $Form_Factor) {
|
||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
process {
|
||||
if ($null -ne $Form_Factor) {
|
||||
$PSBoundParameters.Form_Factor = ValidateDCIMChoice -ProvidedValue $Form_Factor -InterfaceFormFactor
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'interfaces'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
|
|
@ -81,28 +81,30 @@ function Get-NetboxDCIMSite {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($Site_ID in $ID) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $Site_Id))
|
||||
process {
|
||||
switch ($PSCmdlet.ParameterSetName) {
|
||||
'ById' {
|
||||
foreach ($Site_ID in $ID) {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites', $Site_Id))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters -SkipParameterByName "Id"
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
default {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
|
||||
default {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('dcim', 'sites'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments.Clone() -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Raw:$Raw
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachine {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Obtains virtual machines from Netbox.
|
||||
|
||||
|
|
@ -141,15 +141,17 @@ function Get-NetboxVirtualMachine {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
if ($null -ne $Status) {
|
||||
$PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
process {
|
||||
if ($null -ne $Status) {
|
||||
$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 -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
|
|
@ -14,11 +14,11 @@
|
|||
|
||||
function Set-NetboxVirtualMachine {
|
||||
[CmdletBinding(ConfirmImpact = 'Medium',
|
||||
SupportsShouldProcess = $true)]
|
||||
SupportsShouldProcess = $true)]
|
||||
param
|
||||
(
|
||||
[Parameter(Mandatory = $true,
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
ValueFromPipelineByPropertyName = $true)]
|
||||
[uint16]$Id,
|
||||
|
||||
[string]$Name,
|
||||
|
|
@ -50,23 +50,25 @@ function Set-NetboxVirtualMachine {
|
|||
[switch]$Force
|
||||
)
|
||||
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
# if ($null -ne $Status) {
|
||||
# $PSBoundParameters.Status = ValidateVirtualizationChoice -ProvidedValue $Status -VirtualMachineStatus
|
||||
# }
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'virtual-machines', $Id))
|
||||
|
||||
Write-Verbose "Obtaining VM from ID $Id"
|
||||
Write-Verbose "Obtaining VM from ID $Id"
|
||||
|
||||
#$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
|
||||
#$CurrentVM = Get-NetboxVirtualMachine -Id $Id -ErrorAction Stop
|
||||
|
||||
Write-Verbose "Finished obtaining VM"
|
||||
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'
|
||||
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
|
||||
$URI = BuildNewURI -Segments $URIComponents.Segments
|
||||
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -13,7 +13,7 @@
|
|||
|
||||
|
||||
function Get-NetboxVirtualMachineInterface {
|
||||
<#
|
||||
<#
|
||||
.SYNOPSIS
|
||||
Gets VM interfaces
|
||||
|
||||
|
|
@ -84,11 +84,13 @@ function Get-NetboxVirtualMachineInterface {
|
|||
[switch]$Raw
|
||||
)
|
||||
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||
process {
|
||||
$Segments = [System.Collections.ArrayList]::new(@('virtualization', 'interfaces'))
|
||||
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
$URIComponents = BuildURIComponents -URISegments $Segments -ParametersDictionary $PSBoundParameters
|
||||
|
||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
$uri = BuildNewURI -Segments $URIComponents.Segments -Parameters $URIComponents.Parameters
|
||||
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
InvokeNetboxRequest -URI $uri -Raw:$Raw
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue