PowerShell Genie

How would you design safe WhatIf and Confirm behavior in a function?

Question 1 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Use SupportsShouldProcess on an advanced function and call $PSCmdlet.ShouldProcess around the state-changing operation.

Interview · Question 17 of 34

Answer before reveal

Your draft

Write the answer you would give in an interview. The model answer stays hidden until you have drafted at least a short response.

Primary documentation

Windows services and processes documentation

Continue
Genie guideHow would you design safe WhatIf and Confirm behavior in a function?

Use SupportsShouldProcess on an advanced function and call $PSCmdlet.ShouldProcess around the state-changing operation.