description | ms.custom | ms.date | ms.topic | title |
---|---|---|---|---|
Use ShouldProcess For State Changing Functions |
PSSA v1.21.0 |
06/28/2023 |
reference |
UseShouldProcessForStateChangingFunctions |
Severity Level: Warning
Functions whose verbs change system state should support ShouldProcess
.
Verbs that should support ShouldProcess
:
New
Set
Remove
Start
Stop
Restart
Reset
Update
Include the SupportsShouldProcess
argument in the CmdletBinding
attribute.
function Set-ServiceObject
{
[CmdletBinding()]
param
(
[string]
$Parameter1
)
...
}
function Set-ServiceObject
{
[CmdletBinding(SupportsShouldProcess = $true)]
param
(
[string]
$Parameter1
)
...
}