PowerTip: Redirect PowerShell Warning Messages to a Text File

Doctor Scripto

Summary: Use the warning redirection operator to redirect Windows PowerShell warning messages to a text file.

Hey, Scripting Guy! Question How can you prevent warning messages from displaying to the Windows PowerShell host, but instead capture them in a text file?

Hey, Scripting Guy! Answer Use the warning message redirection operator:

$WarningPreference = “continue”

 Write-Warning “this is warning” 3> c:\fso\warning.txt

0 comments

Discussion is closed.

Feedback usabilla icon