• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 7319
  • Last Modified:

E-Mail alerts for Windows Server Backup 2012 based on eventID trigger

Can someone please help me with a method of sending E-Mail alerts for the Windows Server 2012 backup utility based on eventID for successful and failed backups?
0
BobTheITGuy
Asked:
BobTheITGuy
  • 10
  • 9
1 Solution
 
Felix LevenSenior System and DatabaseadministratorCommented:
The link shows a good colleciton of all the eventid's showing that something is wrong with your backup and how to set the Trigger in the eventlog.

http://crashmag.net/windows-server-backup-notifications

Using a Little powershell script can be more dynamic:
http://focusedit.co.uk/blog/76-windows-server-backup-send-email-when-complete
0
 
BobTheITGuyAuthor Commented:
Yes, I understand the process in the link attached but it does not apply to Windows Server 2012 standard as the feature had been discontinued.  Are there any other options available?
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
In Server 2012 Server Manager Dashboard go to "Add roles and features" and then in the wizard select the option "Windows Server Backup" under features.

It is different, it does not like backup to tape, but it's there.
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

 
BobTheITGuyAuthor Commented:
Yes, I have the Windows Backup installed and functional.  But when I try to configure an E-mail alert from a task, the system returns the message:

"An error has occurred for task
 Microsoft-Windows-Backup_Microsoft-Windows-Backup_4.  Error message: The following error was reported: The task definition uses a deprecated feature.
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
Yes, second link pls. I was not sure about it.

Sending email ist not possible anymore (never used it myself), but starting a powershell script and sending mail from the script works.
0
 
BobTheITGuyAuthor Commented:
Just attempted the powershell function and within the EventViewer task results, the task did not send an E-mail and returned the "last run result" of "Incorrect function. (0x80070001).  Can you offer any help?
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
The account must have the
Logon as a batch job\Log on as a service permission on the local machine.

What user do you use to execute the trigger in taskplaner ?
0
 
BobTheITGuyAuthor Commented:
For now the domain admin account so as to minimize the risk of permissions issues.
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
I have tested it myself and it is working.

Is "Set-ExecutionPolicy RemoteSigned" set in powershell ?
0
 
BobTheITGuyAuthor Commented:
I think I have it set for the script but when I execute, this is the first section of output:

add-pssnapin : No snap-ins have been registered for Windows PowerShell version 3.
At C:\BackupEmail\EmailBackupResults.ps1:10 char:1
+ add-pssnapin windows.serverbackup
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (windows.serverbackup:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.AddPSSnapinCommand
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
Change:
add-pssnapin windows.serverbackup

to
Import-Module WindowsServerBackup
0
 
BobTheITGuyAuthor Commented:
A different error message appeared this time (below), I'm not familiar with PowerShell yet at all but is there some config/setup required?

Import-Module : The specified module 'WindowsServerBackup' was not loaded because no valid module file was found in any
module directory.
At C:\BackupEmail\EmailBackupResults.ps1:10 char:1
+ Import-Module WindowsServerBackup
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ResourceUnavailable: (WindowsServerBackup:String) [Import-Module], FileNotFoundException
    + FullyQualifiedErrorId : Modules_ModuleNotFound,Microsoft.PowerShell.Commands.ImportModuleCommand
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
ok, sorry for the confusion Import only works in 2012 R2 Server.


Add-Pssnapin windows.serverbackup -> should load all the commands to work with Windows backup and is used in the powershell sctipt.

But, they are missing and can't be added by the command Add-Pssnapin windows.serverbackup.

Solution:
In the Add Features Wizard, on the Select Features page, expand Windows Server Backup Features, and then select the check boxes for Windows Server Backup and Command-line Tools.
0
 
BobTheITGuyAuthor Commented:
On my server, I don't have any option to expand the "Windows Server Backup".  Could it be located somewhere else?
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
Just delete the line add-pssnapin, powershell will load what it needs on 2012 server.
0
 
BobTheITGuyAuthor Commented:
No success with this option either.  I think I'll move to another option until I become a little more experienced with PowerShell.
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
one more try please. For now we keep it simple:
# Set up variables
$SmtpServer = "192.168.1.1"
$SmtpPort = 25
$FromEmail = "admin-email-address"
$ToEmail = "recipient-email-address"

# Construct and send email
$SmtpClient = new-object system.net.mail.smtpClient
$Msg = new-object Net.Mail.MailMessage
$SmtpClient.host = $SmtpServer
$SmtpClient.Port = $SmtpPort
$computer = gc env:computername
$Msg.From = $FromEmail
$Msg.To.Add($ToEmail)
$Msg.Subject = "## Backup Complete on " +$Computer +" ##"
$Msg.Body = "The backup for " +$Computer+" has completed. Please see the attached file for backup results."
$SmtpClient.Send($Msg)

Open in new window

0
 
BobTheITGuyAuthor Commented:
Huge step forward.  Mail is being sent now but no attachment.  Is there something further I need to configure?
0
 
Felix LevenSenior System and DatabaseadministratorCommented:
I skiped the attachment, because this is the part  thats not working on your server. You must find out why the backup powershell commands are missing on your server.

To continue, just make a script for every success and failedl eventid (first link) you are interested in and change the subject of the mail send. If a mail arrives you can go and check the backup logs.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

  • 10
  • 9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now