October 2017
Intermediate to advanced
440 pages
11h 47m
English
The WhatIf parameter replaces the confirmation prompt with a simple statement that should state what would have been done using Remove-Item as an example again:
PS> Set-Location $env:TEMPNew-Item IMadeThisUp.txt -ForceRemove-Item .\IMadeThisUp.txt -WhatIf ConfirmAre you sure you want to perform this action?What If: Performing the operation "Remove File" on target "C:\Users\whoami\AppData\Local\Temp\IMadeThisUp.txt".
If both Confirm and WhatIf are used with a command, WhatIf takes precedence.
WhatIf may be unset on a per-command basis by supplying a value of false in the same manner as the Confirm parameter. Let's look at the following example:
'Some message' | Out-File $env:TEMP\test.txt -WhatIf:$false
The previous technique ...
Read now
Unlock full access