Learn about Windows PowerShell
Summary: Use the warning redirection operator to redirect Windows PowerShell warning messages to a text file.
How can you prevent warning messages from displaying to the Windows PowerShell host, but instead capture them in a text file?
Use the warning message redirection operator:
$WarningPreference = "continue"
Write-Warning "this is warning" 3> c:\fso\warning.txt
Is the entire Warning Message supposed to be directed to the .txt file or just what you specify in Write-Warning "" ?
#off topic but it finally hit me this folder you always use
Does fso = File System Object?
if $answer -eq $True then "duuuude!!!"
else {dim lightbulb}
@Vern_Anderson yes, it stands for file system object :-) it is just part of my sick sense of humor -- I love using an anachronistic reference to a legacy scripting language inside a modern scripting and automation environment. Besides, it is really easy to type --- I could call it ben I guess .....
@Tim it redirects the specific stream, so not all warnings will redirect, unless you place the redirection at the point where you call the script.
myscript.ps1 3> warnings.txt