You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When you create an advanced function that uses the SupportsShouldProcess flag in the CmdletBinding attribute, you obviously want to support Confirm/WhatIf scenarios. Given that is the case, at a glance it appears to make sense to check to see if ShouldProcess/ShouldContinue are used in these functions; however, functions very often are nothing more than a wrapper around one or more PowerShell commands that they invoke internally.
If the commands invoked by a function support ShouldProcess as well, as they very often do, then in practice you don't really need to call ShouldProcess/ShouldContinue much at all. Sometimes it makes sense to do so, depending on the logic inside of the function, but often times you simply don't need it because the commands you invoke have that covered already.
Therefore, the PSShouldProcess rule should only ever raise a warning when the function where it is used does not invoke ShouldProcess/ShouldContinue AND when the function where it is used does not contain any other commands that support ShouldProcess. Otherwise you're just guessing and, in the case of many of my own modules, you're guessing incorrectly and creating noise.
The text was updated successfully, but these errors were encountered:
When you create an advanced function that uses the SupportsShouldProcess flag in the CmdletBinding attribute, you obviously want to support Confirm/WhatIf scenarios. Given that is the case, at a glance it appears to make sense to check to see if ShouldProcess/ShouldContinue are used in these functions; however, functions very often are nothing more than a wrapper around one or more PowerShell commands that they invoke internally.
If the commands invoked by a function support ShouldProcess as well, as they very often do, then in practice you don't really need to call ShouldProcess/ShouldContinue much at all. Sometimes it makes sense to do so, depending on the logic inside of the function, but often times you simply don't need it because the commands you invoke have that covered already.
Therefore, the PSShouldProcess rule should only ever raise a warning when the function where it is used does not invoke ShouldProcess/ShouldContinue AND when the function where it is used does not contain any other commands that support ShouldProcess. Otherwise you're just guessing and, in the case of many of my own modules, you're guessing incorrectly and creating noise.
The text was updated successfully, but these errors were encountered: