I had recently to reset a bunch of user accounts.
Before informing people about the change, and in order to test my script I used the WhatIf
parameter.
Unfortunately, the Set-ADAccountPassword
cmdlet didn’t return anything…
And after a few minutes, people started to call for help about their password…
I didn’t know that this is a known bug.
So should we be scared to use the WhatIf parameter?
No, but some safety measures could be helpful to avoid embarrassing situations:
1. Make a test on an object for which there are no bad consequences if the WhatIf parameter fails
2. Ensure that in the output you see a line starting with What if:
Update:
Just came through another cmdlet which ignores the WhatIf
parameter and which is the Set-Volume
cmdlet.
More about
Weekend Scripter: Easily Add Whatif Support to Your PowerShell Functions (Hey, Scripting Guy! Blog)