Bird
0
0

To enable the -Confirm parameter in a PowerShell advanced function, which attribute must be included?

easy📝 Conceptual Q2 of 15
PowerShell - Scripting Best Practices
To enable the -Confirm parameter in a PowerShell advanced function, which attribute must be included?
A[ValidateNotNullOrEmpty()]
B[Parameter(Mandatory=$true)]
C[OutputType([bool])]
D[CmdletBinding(SupportsShouldProcess=$true)]
Step-by-Step Solution
Solution:
  1. Step 1: Identify attribute for confirmation support

    The [CmdletBinding(SupportsShouldProcess=$true)] attribute enables the function to support -Confirm and -WhatIf.
  2. Step 2: Understand other attributes

    Other attributes like [Parameter(Mandatory=$true)] control parameter behavior but do not enable confirmation support.
  3. Final Answer:

    [CmdletBinding(SupportsShouldProcess=$true)] -> Option D
  4. Quick Check:

    SupportsShouldProcess enables -Confirm [OK]
Quick Trick: SupportsShouldProcess enables -Confirm support [OK]
Common Mistakes:
  • Confusing parameter attributes with cmdlet binding
  • Using mandatory parameter attribute for confirmation
  • Assuming output type affects confirmation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes