Warning, Verbose and Debug streams do not respect action preferences the way they should
Votes from Connect: 33
Original Date Submitted: 3/12/2010 7:45:29 PM
Handle: Kirk Munro (Quest Software)
Site Name: PowerShell
Feedback ID: 541500
Frequency: Always Happens
Regression: Yes, this happens in all previous versions
If you use the preference variables or the -WarningAction common parameter to control how warnings are handled in PowerShell, or if you use the preference variables to control how verbose or debug messages are handled in PowerShell, your control efforts are ignored because the warning, verbose or debug messages are displayed every time anyway.
This differs from how preference variables and the -ErrorAction common parameter affect errors, where you can decide what to do with the error before it is sent to the error stream, including controlling whether or not it is sent to the error stream.
Each of these message streams should be handled consistently, allowing you to control what is sent to the stream and what is simply processed internally by your script.
Product Studio item created by Connect Synchronizer due to creation of feedback ID 541500 (http://connect.microsoft.com/PowerShell/feedback/ViewFeedback.aspx?FeedbackID=541500).
$warningPreference = 'Stop'
Write-Warning 'I''m warning you!'
Write-Host 'After Write-Warning call'
'Outside my script block'
After Write-Warning call
Outside my script block
Note: the warning text should not be displayed, but at the moment it is displayed before the trap statement is even entered
Internal BugId: 2466