powershell script to capture the errors from excuting command


i have powershell script needs to run command line,  want capture error occures when excuting command line , return separate file or email address.

is can done powershell?

-sam

what this

$x = invoke-expression -command "echo test"

$x # display stdout

$x | out-file c:\test\mytest.txt # save file

send-mailmessage -to $to -from $from -smtp $smtp -body $x -subject "my test"

of course you'll have set $to,$from,$smtp varaibles



Windows Server  >  Windows PowerShell



Comments

Popular posts from this blog

server manager error: ADAM.events.xml could not be enumerated.

Cannot access Anywhere Access using domain name?

WMI Failure: Unable to update Local Resource Group