PSSA: Fix PSUseShouldProcessForStateChangingFunctions

Function New-/Set-... has verb that could change system state. Therefore, the function has to support 'ShouldProcess'
This commit is contained in:
Alexis La Goutte 2021-07-23 21:20:20 +02:00
parent 1ca534b3a4
commit 0d28d3ef01
5 changed files with 52 additions and 36 deletions

View file

@ -13,7 +13,8 @@
function New-NetboxDCIMDevice {
[CmdletBinding()]
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
#region Parameters
param
@ -86,5 +87,7 @@ function New-NetboxDCIMDevice {
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Name, 'Create new Device')) {
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method POST
}
}

View file

@ -13,7 +13,8 @@
function Set-NetboxDCIMInterface {
[CmdletBinding()]
[CmdletBinding(ConfirmImpact = 'Medium',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
@ -88,9 +89,11 @@ function Set-NetboxDCIMInterface {
$URI = BuildNewURI -Segments $Segments
if ($Force -or $pscmdlet.ShouldProcess("Interface ID $($CurrentInterface.Id)", "Set")) {
InvokeNetboxRequest -URI $URI -Body $URIComponents.Parameters -Method PATCH
}
}
}
end {

View file

@ -13,6 +13,8 @@
function New-NetboxIPAMPrefix {
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
[CmdletBinding()]
param
(
@ -55,5 +57,7 @@ function New-NetboxIPAMPrefix {
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($Prefix, 'Create new Prefix')) {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
}
}

View file

@ -40,7 +40,8 @@
Additional information about the function.
#>
[CmdletBinding()]
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
@ -75,5 +76,7 @@
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($nae, 'Create new Vlan $($vid)')) {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters -Raw:$Raw
}
}

View file

@ -13,7 +13,8 @@
function New-NetboxVirtualMachine {
[CmdletBinding()]
[CmdletBinding(ConfirmImpact = 'low',
SupportsShouldProcess = $true)]
[OutputType([pscustomobject])]
param
(
@ -61,8 +62,10 @@ function New-NetboxVirtualMachine {
$URI = BuildNewURI -Segments $URIComponents.Segments
if ($PSCmdlet.ShouldProcess($name, 'Create new Virtual Machine')) {
InvokeNetboxRequest -URI $URI -Method POST -Body $URIComponents.Parameters
}
}