question

JohnnyMongstad-9727 avatar image
0 Votes"
JohnnyMongstad-9727 asked RichMatheisen-8856 answered

Powershell -WhatIf parameter was ignored

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-generalwindows-server-powershell
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

RichMatheisen-8856 avatar image
0 Votes"
RichMatheisen-8856 answered

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://docs.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.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.