Detalhando erros no Powershell

Estou montando um script em Powershell para enviar um mail caso aconteça algumas situações e no momento do teste aparecia a seguinte mensagem de erro:

Exception calling “Send” with “4” argument(s): “Failure sending mail.”
At line:1 char:11
+ $smtp.Send <<<< (“teste@merazzi.eti.br”,”teste@merazzi.eti.br”,”teste de e-mail”,”Teste de mail”)
+ CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException

Como esse erro não diz muita coisa, fui no pai dos burros (a.k.a Google) e achei o seguinte comando:

Com isso, a mensagem veio assim:

Exception             : System.Management.Automation.MethodInvocationException: Exception calling “Send” with “4” argument(s): “Failure sending mail.” —> System.Net.Mail.SmtpException: Failure sending mail. —>
System.Net.WebException: The remote name could not be resolved: ‘asdlçkaçd.com.br’
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
— End of inner exception stack trace —
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at Send(Object , Object[] )
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
— End of inner exception stack trace —
at System.Management.Automation.DotNetAdapter.AuxiliaryMethodInvoke(Object target, Object[] arguments, MethodInformation methodInformation, Object[] originalArguments)
at System.Management.Automation.ParserOps.CallMethod(Token token, Object target, String methodName, Object[] paramArray, Boolean callStatic, Object valueToSet)
at System.Management.Automation.MethodCallNode.InvokeMethod(Object target, Object[] arguments, Object value)
at System.Management.Automation.MethodCallNode.Execute(Array input, Pipe outputPipe, ExecutionContext context)
at System.Management.Automation.ParseTreeNode.Execute(Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
at System.Management.Automation.StatementListNode.ExecuteStatement(ParseTreeNode statement,Array input, Pipe outputPipe, ArrayList& resultList, ExecutionContext context)
TargetObject          :
CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
FullyQualifiedErrorId : DotNetMethodException
ErrorDetails          :
InvocationInfo        : System.Management.Automation.InvocationInfo
PipelineIterationInfo : {}
PSMessageDetails      :

Então se vocês passarem por algum erro “estranho” ao criar os seus scripts, esse carinha é uma mão na roda!

Abraços!

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Esse site utiliza o Akismet para reduzir spam. Aprenda como seus dados de comentários são processados.