PowerShell Utilizzare ShouldProcess () con un argomento


if ($PSCmdlet.ShouldProcess("Target of action")) {
    # Do the thing

Quando si utilizza -WhatIf :

What if: Performing the action "Invoke-MyCmdlet" on target "Target of action"

Quando si utilizza -Confirm :

Are you sure you want to perform this action?
Performing operation "Invoke-MyCmdlet" on target "Target of action"
[Y] Yes  [A] Yes to All  [N] No  [L] No to All  [S] Suspend  [?] Help (default is "Y"):