The WhatIfpreference variable holds a Boolean (true or false) value and has a default value of false.
If the preference variable is set to true, all commands that support WhatIf will act as if the parameter is explicitly set. A new value may be set for the variable as shown in the following code:
$WhatIfPreference = $true
The WhatIf preference variable takes precedence over the Confirm parameter. For example, the WhatIf dialog will be shown when running the following New-Item, the Confirm prompt will not:
$WhatIfPreference = $true New-Item NewFile.txt -Confirm