

Functions that use ShouldContinue should have a boolean force parameter |
Functions that use ShouldContinue should have a boolean force parameter to allow bypassing the prompt
CheckId | SPC019105 |
---|---|
TypeName | CallShouldContinueWhenShouldProcessTrue |
Severity | CriticalWarning |
Type | PowerShell File |
Bad Practice (no force parameter)
Begin
{
}
Process
{
if($pscmdlet.ShouldProcess("foo","bar"))
{
}
}
End
{
if($pscmdlet.ShouldContinue("Yes", "No"))
{
}
}
Good Practice{
}
Process
{
if($pscmdlet.ShouldProcess("foo","bar"))
{
}
}
End
{
if($pscmdlet.ShouldContinue("Yes", "No"))
{
}
}
param ([boolean]$force = $false)
Begin
{
}
Process
{
if($pscmdlet.ShouldProcess("foo","bar"))
{
}
}
End
{
if($pscmdlet.ShouldContinue("Yes", "No"))
{
}
}
Begin
{
}
Process
{
if($pscmdlet.ShouldProcess("foo","bar"))
{
}
}
End
{
if($pscmdlet.ShouldContinue("Yes", "No"))
{
}
}
Disclaimer: The views and opinions expressed in this documentation and in SPCAF do not necessarily reflect the opinions and recommendations of Microsoft or any member of Microsoft. SPCAF and RENCORE are registered trademarks of Rencore. All other trademarks, service marks, collective marks, copyrights, registered names, and marks used or cited by this documentation are the property of their respective owners.