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