Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Severity Level: Warning
Description
Functions whose verbs change system state should support ShouldProcess. To enable the
ShouldProcess feature, set the SupportsShouldProcess argument in the CmdletBinding attribute.
The SupportsShouldProcess argument adds Confirm and WhatIf parameters to the function. The
Confirm parameter prompts the user before it runs the command on each object in the pipeline.
The WhatIf parameter lists the changes that the command would make, instead of running the
command.
Verbs that should support ShouldProcess:
NewSetRemoveStartStopRestartResetUpdate
How
Include the SupportsShouldProcess argument in the CmdletBinding attribute.
Example
Wrong
function Set-ServiceObject
{
[CmdletBinding()]
param
(
[string]
$Parameter1
)
...
}
Correct
function Set-ServiceObject
{
[CmdletBinding(SupportsShouldProcess = $true)]
param
(
[string]
$Parameter1
)
...
}