Bird
0
0

Why does the -WhatIf parameter not execute the action but -Confirm may still execute it after confirmation?

hard📝 Conceptual Q10 of 15
PowerShell - Scripting Best Practices
Why does the -WhatIf parameter not execute the action but -Confirm may still execute it after confirmation?
A<code>-WhatIf</code> disables the command; <code>-Confirm</code> forces execution
B<code>-WhatIf</code> only simulates; <code>-Confirm</code> asks user and runs if confirmed
C<code>-WhatIf</code> logs output; <code>-Confirm</code> skips logging
D<code>-WhatIf</code> requires admin rights; <code>-Confirm</code> does not
Step-by-Step Solution
Solution:
  1. Step 1: Understand difference between -WhatIf and -Confirm

    -WhatIf simulates the command without running it; -Confirm prompts user and runs if confirmed.
  2. Step 2: Evaluate options

    Only -WhatIf only simulates; -Confirm asks user and runs if confirmed correctly describes this behavior.
  3. Final Answer:

    -WhatIf only simulates; -Confirm asks user and runs if confirmed -> Option B
  4. Quick Check:

    -WhatIf simulates, -Confirm prompts = B [OK]
Quick Trick: -WhatIf previews; -Confirm prompts before running [OK]
Common Mistakes:
  • Thinking -WhatIf disables command permanently
  • Assuming -Confirm forces execution without prompt
  • Confusing logging with simulation

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More PowerShell Quizzes