One of the principal needs for BizTalk Administrators is the ability to monitor the health of BizTalk environments on a regular basis and react promptly to solve any possible issues that may appear in order to keep your BizTalk Server applications accessible to your users/organization.
You can accomplish this by using certain tools such as BizTalk Administration Console; BizTalk360; SCOM and many more… However, unfortunately, many times, some of these tools are not available for us but we still need to accomplish this task.
However sometimes we don’t have access to some of these tools and in this case, PowerShell is a good way to address and implement some of the basic monetization tasks or even complement and extend the existing tools.
Now I’m playing a little with PowerShell… following my last post and the series “Monitor your BizTalk environment using PowerShell”.
So how can PowerShell help us?
BizTalk Server writes all errors that occur in the environment in the Event Viewer Application Log.
It is important that you maintain this log clean of noise (custom application errors, warnings of information that you can use inside your code)
With this script, you can be able to monitor the Event Viewer for BizTalk Server related errors
This script allows you to set:
- The timeframe that you want to monitor, the Entry Type and the Sources
$getEventLog = Get-Eventlog -log application -after ((get-date).AddHours(-4)) -EntryType Error | Where-Object {($_.Source -eq 'BizTalk Server')}
- And configure your email notification settings
Set mail variables [STRING]$PSEmailServer = "smtp" [STRING]$Subject = "BizTalk Job Monitor" [STRING]$From = "biztalk@monitor.com" [array]$EmailTo = ("support@biztalk.com") if($count -gt 0) { #Send mail foreach ($to in $EmailTo) { $Body = $HTMLmessage $SMTPClient = New-Object Net.Mail.SmtpClient($PSEmailServer) $message = New-Object Net.Mail.MailMessage($from, $to, $Subject, $Body) $message.IsBodyHtml = $true; $SMTPClient.Send($message) } }
Report sample:
Note: This type of script must be viewed as a complement to the tools mentioned above or used in the absence of them.
Download
THIS POWERSHELL IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND.
You can download Monitoring Event Viewer Errors in your BizTalk environment with PowerShell from GitHub here:
Very usefull script for event handling thnx..
In pshell script you should use $log instead of $getEventLog for avoid looping.