Powershell -WhatIf parameter was ignored

Johnny Mongstad 21 Reputation points
2021-11-10T19:52:23.87+00:00

I was exploring the outcome of a powershell command after seeing a question asked on the stackoverflow forum.
Using -WhatIf parameter when the command was run was ignored by the console and it ran it through

In the past we have used the -WhatIf parameter many times. Especially before running commands towards active directory.
But now when I ran this command it just went on and formatted the drive. This has to be a bug?

Format-Volume -WhatIf -DriveLetter D -FileSystem NTFS  

148333-powershell-2021-11-10-20-47-18.png

Here's an example where the -WhatIf parameter does it's job

148219-powershell-2021-11-10-20-49-04.png

I think I will never trust the -WhatIf parameter again

Windows for business Windows Server User experience PowerShell
Windows for business Windows Client for IT Pros User experience Other
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 47,901 Reputation points
    2021-11-10T20:08:38.467+00:00

    Looks like a bug to me -- but it isn't necessarily a bug in the code. There are times that the documentation (and HELP cmdlet output) for a cmdlet are wrong.

    If I were you, I'd first get the contents of the $PSVersionTable and verify you're using version 5.1. Next, visit the Format-Volume online documentation (format-volume ) and all the way at the bottom of the page, you'll find the "Feedback" section. Click on the "This page" button and describe your problem and provide the output of $PSVersionTable as supporting evidence, along with a link to this post (https://learn.microsoft.com/en-us/answers/questions/622675/powershell-whatif-parameter-was-ignored.html).

    The document folks will verify with the developers that the -WhatIf swich is supported. If it's not they'll at lease update the documentation. They'll also file a bug report, but that won't be fixed right away.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.