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 10
Windows 10
A Microsoft operating system that runs on personal computers and tablets.
10,697 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,389 questions
0 comments No comments
{count} votes

Accepted answer
  1. Rich Matheisen 45,096 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