Cmdlet.ShouldProcess
Method
Definition
Overloads
| ShouldProcess(String, String, String, ShouldProcessReason) |
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
|
| ShouldProcess(String, String, String) |
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
|
| ShouldProcess(String, String) |
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
|
| ShouldProcess(String) |
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed. |
ShouldProcess(String, String, String, ShouldProcessReason)
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
This variant allows the caller to specify the complete text
describing the operation, rather than just the name and action.
public bool ShouldProcess (string verboseDescription, string verboseWarning, string caption, out System.Management.Automation.ShouldProcessReason shouldProcessReason);
- verboseDescription
- String
Textual description of the action to be performed. This is what will be displayed to the user for ActionPreference.Continue.
- verboseWarning
- String
Textual query of whether the action should be performed, usually in the form of a question. This is what will be displayed to the user for ActionPreference.Inquire.
- caption
- String
Caption of the window which may be displayed
if the user is prompted whether or not to perform the action.
caption may be displayed by some hosts, but not all.
- shouldProcessReason
- ShouldProcessReason
Indicates the reason(s) why ShouldProcess returned what it returned. Only the reasons enumerated in ShouldProcessReason are returned.
If ShouldProcess returns true, the operation should be performed. If ShouldProcess returns false, the operation should not be performed, and the Cmdlet should move on to the next target resource.
The pipeline has already been terminated, or was terminated during the execution of this method. The Cmdlet should generally just allow PipelineStoppedException to percolate up to the caller of ProcessRecord etc.
Not permitted at this time or from this thread. ShouldProcess may only be called during a call to this Cmdlet's implementation of ProcessRecord, BeginProcessing or EndProcessing, and only from that thread.
Remarks
A Cmdlet should declare [Cmdlet( SupportsShouldProcess = true )] if-and-only-if it calls ShouldProcess before making changes.
ShouldProcess may only be called during a call to this Cmdlet's
implementation of ProcessRecord, BeginProcessing or EndProcessing,
and only from that thread.
ShouldProcess will take into account command-line settings
and preference variables in determining what it should return
and whether it should prompt the user.
ShouldProcess(String, String, String)
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
This variant allows the caller to specify the complete text
describing the operation, rather than just the name and action.
public bool ShouldProcess (string verboseDescription, string verboseWarning, string caption);
- verboseDescription
- String
Textual description of the action to be performed. This is what will be displayed to the user for ActionPreference.Continue.
- verboseWarning
- String
Textual query of whether the action should be performed, usually in the form of a question. This is what will be displayed to the user for ActionPreference.Inquire.
- caption
- String
Caption of the window which may be displayed
if the user is prompted whether or not to perform the action.
caption may be displayed by some hosts, but not all.
If ShouldProcess returns true, the operation should be performed. If ShouldProcess returns false, the operation should not be performed, and the Cmdlet should move on to the next target resource.
The pipeline has already been terminated, or was terminated during the execution of this method. The Cmdlet should generally just allow PipelineStoppedException to percolate up to the caller of ProcessRecord etc.
Not permitted at this time or from this thread. ShouldProcess may only be called during a call to this Cmdlet's implementation of ProcessRecord, BeginProcessing or EndProcessing, and only from that thread.
Remarks
A Cmdlet should declare [Cmdlet( SupportsShouldProcess = true )] if-and-only-if it calls ShouldProcess before making changes.
ShouldProcess may only be called during a call to this Cmdlet's
implementation of ProcessRecord, BeginProcessing or EndProcessing,
and only from that thread.
ShouldProcess will take into account command-line settings
and preference variables in determining what it should return
and whether it should prompt the user.
ShouldProcess(String, String)
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
This variant allows the caller to specify text for both the
target resource and the action.
public bool ShouldProcess (string target, string action);
- target
- String
Name of the target resource being acted upon. This will potentially be displayed to the user.
- action
- String
Name of the action which is being performed. This will potentially be displayed to the user. (default is Cmdlet name)
If ShouldProcess returns true, the operation should be performed. If ShouldProcess returns false, the operation should not be performed, and the Cmdlet should move on to the next target resource.
The pipeline has already been terminated, or was terminated during the execution of this method. The Cmdlet should generally just allow PipelineStoppedException to percolate up to the caller of ProcessRecord etc.
Not permitted at this time or from this thread. ShouldProcess may only be called during a call to this Cmdlet's implementation of ProcessRecord, BeginProcessing or EndProcessing, and only from that thread.
Remarks
A Cmdlet should declare [Cmdlet( SupportsShouldProcess = true )] if-and-only-if it calls ShouldProcess before making changes.
ShouldProcess may only be called during a call to this Cmdlet's
implementation of ProcessRecord, BeginProcessing or EndProcessing,
and only from that thread.
ShouldProcess will take into account command-line settings
and preference variables in determining what it should return
and whether it should prompt the user.
ShouldProcess(String)
Confirm the operation with the user. Cmdlets which make changes (e.g. delete files, stop services etc.) should call ShouldProcess to give the user the opportunity to confirm that the operation should actually be performed.
public bool ShouldProcess (string target);
- target
- String
Name of the target resource being acted upon. This will potentially be displayed to the user.
If ShouldProcess returns true, the operation should be performed. If ShouldProcess returns false, the operation should not be performed, and the Cmdlet should move on to the next target resource.
The pipeline has already been terminated, or was terminated during the execution of this method. The Cmdlet should generally just allow PipelineStoppedException to percolate up to the caller of ProcessRecord etc.
Not permitted at this time or from this thread. ShouldProcess may only be called during a call to this Cmdlet's implementation of ProcessRecord, BeginProcessing or EndProcessing, and only from that thread.
Remarks
A Cmdlet should declare [Cmdlet( SupportsShouldProcess = true )] if-and-only-if it calls ShouldProcess before making changes.
ShouldProcess may only be called during a call to this Cmdlet's
implementation of ProcessRecord, BeginProcessing or EndProcessing,
and only from that thread.
ShouldProcess will take into account command-line settings
and preference variables in determining what it should return
and whether it should prompt the user.