login vsi company logo login vsi company logo 250x40

How to configure Login PI to send alerts via e-mail

How to configure Login PI to send alerts via e-mail

A huge advantage of Login PI is the fact that it will automatically generate alerts about performance in your virtualized desktop environment--before your end users start to notice issues. These alerts are displayed in the Login PI event log. But what if you are not checking the interface because you are off getting a nice cup of coffee? Wouldn’t it be great if you could automatically receive these alerts in your email Inbox as well? In this blog post I will explain how to set up Login PI to send alerts via email.

You may also be interested my colleague Omar’s recent post that goes into greater detail on associating tasks with PI alerts – today’s post shows how you can generate an email in one of those tasks.

Login PI writes every warning/error in the event log. With the task scheduler (built into Windows) you can attach tasks to the event log. So, let’s get started.

First, we should create a script that can mail the event logs. An easy way to do this is by copying the one I’ve made below. Don’t forget to adjust the email addresses and SMTP server settings: username, password, SMTP server and port (otherwise I will receive all your alerts ). Save the file afterwards as a PowerShell file (.ps1). Remember the location where you saved it because we will need it later on.

$event = get-eventlog -LogName "PI - Alerts" -newest 1
$EmailBody = $event.Message
$EmailFrom = "change.this@example.com"
$EmailTo = "change.this@example.com" 
$SMTPServer = "smtp.office365.com"
$username = "change.this@example.com"
$passwordtext = "MyP@ssw0rd!"
$password = ConvertTo-SecureString -AsPlainText $passwordtext -Force
$credentials = new-object -typename System.Management.Automation.PSCredential -argumentlist $username, $password
if ($event.EntryType -eq "Warning")
    Write-host "Sending Email Warning"
    $EmailSubject = "Login PI - Warning"
elseif ($event.EntryType -eq "Error")
    Write-host "Sending Email Error"
    $EmailSubject = "Login PI - Error"
Send-MailMessage -From $EmailFrom -To $EmailTo –Subject $EmailSubject –Body $EmailBody -SmtpServer $SMTPServer -Credential $credentials -UseSsl -Port 587 

Now that we have created a mail script, we can open the event log. On the server where Login PI is installed, we go to Application and Services Logs -> PI Alerts. Right-click PI - Alerts and click Attach a Task To this Log.

how to configure login pi to send alerts via e mail attach a task to this log

A Create Basic Task Wizard will appear. Enter your task a name and continue until you can add the program or script. Add the powershell.exe in the program/script bar and add the mail script as argument. Place the ‘-file’ parameter in front of it. Be aware that if your PowerShell- or mail script location contains white spaces you will need to add quotes.

how to configure login pi to send alerts via e mail create a basic task

After we’ve added the script and pressed Next, we should mark as open the properties of the new task. Also make sure to select ‘Run whether user is logged on or not’ option, otherwise you will not be notified when you are logged off.

how to configure login pi to send alerts via e mail jasper geelen

The job is done! Time to relax and grab a cup of coffee until you get alerted.

About the author

Jasper Geelen (@jaspergeelen) has a background in ICT and joined Login VSI as a pre-sales engineer in 2015. He loves drinking a lot of coffee (some might call him an addict). In his spare time, Jasper enjoys a beer and he is part of a football / soccer team. He also coaches a team of younger football players.

Tags: How-to, Login PI, Monitoring, Best Practices, Support, Scripts

Start Delivering the Best End User Experience Today

Request a Demo

Login VSI, Inc.

3945 Freedom Circle
Suite 670
Santa Clara, CA 95054

Phone: +1 408 899 7418

Login VSI B.V.

De Entree 85
1101 BH Amsterdam
The Netherlands

Phone: +31 20 705 1200