Powershell Poison Alert Email
Hi I write a script that send me an email when an email is in the Poison Message Queue: Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin $msg = get-message -queue:Poison write $msg if(get-message -queue:Poison) { $SmtpClient = New-Object system.net.mail.smtpClient $SmtpClient.host = "IP SERVER" #Change to a SMTP server in your environment $MailMessage = New-Object system.net.mail.mailmessage $MailMessage.from = "emailfrom" #Change to email address you want emails to be coming from $MailMessage.To.add("emailto") #Change to email address you would like to receive emails. $MailMessage.Subject = "Attention - Poison Messages" $MailMessage.Body = $msg $SmtpClient.Send($MailMessage) } When I receive the email, in the body I have Microsoft.Exchange.Data.QueueViewer.MessageInfo I want to display the result of the get-message -queue:Poison command Is it possible? Thanks DS
April 20th, 2011 1:44pm

Try this: Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin $msg = get-message -queue:Poison write $msg if($msg) { $OutMsg = $msg | ConvertTo-Html $SmtpClient = New-Object system.net.mail.smtpClient $SmtpClient.host = "IP SERVER" #Change to a SMTP server in your environment $MailMessage = New-Object system.net.mail.mailmessage $MailMessage.from = "emailfrom" #Change to email address you want emails to be coming from $MailMessage.To.add("emailto") #Change to email address you would like to receive emails. $MailMessage.Subject = "Attention - Poison Messages" $MailMessage.Body = ($OutMsg | Out-String) $SmtpClient.Send($MailMessage) } Karl http://unlockpowershell.wordpress.com Co-Author, Windows PowerShell 2.0 Bible -join("6B61726C6D69747363686B65406D742E6E6574"-split"(?<=\G.{2})",19|%{[char][int]"0x$_"})
Free Windows Admin Tool Kit Click here and download it now
April 20th, 2011 5:16pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics