PowerShell Using ShouldProcess

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Syntax

  • $PSCmdlet.ShouldProcess("Target")
  • $PSCmdlet.ShouldProcess("Target", "Action")

Parameters

ParameterDetails
TargetThe resource being changed.
ActionThe operation being performed. Defaults to the name of the cmdlet.

Remarks

$PSCmdlet.ShouldProcess() will also automatically write a message to the verbose output.

PS> Invoke-MyCmdlet -Verbose
VERBOSE: Performing the operation "Invoke-MyCmdlet" on target "Target of action"


Got any PowerShell Question?