Watch Out When Combining -Force and -WhatIf!

by Dec 6, 2016

The -WhatIf common parameter turns on simulation mode, so a cmdlet won’t change anything and instead report what it “would have” changed. This works perfectly well, unless a developer fails to implement -WhatIf correctly.

This is rare, but there is a pattern: when you specify -Force and -WhatIf, the right thing would be to let -WhatIf win. Some developers are so focused on -Force that they let -Force win. Try it with Remove-SmbShare, for example.

Twitter This Tip! ReTweet this Tip!