Quantcast
Channel: Hey, Scripting Guy! Blog
Viewing all articles
Browse latest Browse all 3333

PowerTip: Redirect PowerShell Warning Messages to a Text File

$
0
0

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


Viewing all articles
Browse latest Browse all 3333

Trending Articles