PowerShell script exchange
Post Reply
MTaylorCBC

Integration with ServiceNow

Post by MTaylorCBC »

So I just learned to spell Veeam and PowerShell. I realize this post is old, but has anybody been successful with Veeam integration to ServiceNow?

In our shop, we can send an email to ServiceNow containing specific parms and format to automatically create tickets. Below is an example of the required parms/format. RESTful API's is probably the better approach, but getting resistance using it. Anyway, I'm attempting to create a PowerShell script to run at the end of jobs to identify failures. Any help on creating this code would be great or other suggestions.

~Cheers
Mike

Description: Veeam VM Backup Failure
Catagory: Software / Application
Subcatagory: Failure/Error
Impact: 4
Urgency: 4
Group: Server Services
oleg.feoktistov
Veeam Software
Posts: 1912
Liked: 635 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: Integration with ServiceNow

Post by oleg.feoktistov »

Hi Mike,

As mentioned in the parent topic, we don't have an out-of-the-box solution for ServiceNow integration.
However, if you need to trigger some powershell code towards Veeam from ServiceNow and retrieve some data, in theory, you can try to create a custom powershell activity in ServiceNow Orchestrator and run it against a MID Server, which will connect to a Veeam Backup Server using the information specified in a powershell script.
Script results should be then displayed in ServiceNow Orchestrator Activity logs.

Thank you!
MTaylorCBC

Re: Integration with ServiceNow

Post by MTaylorCBC »

Given the age of this, I was hoping another customer had something. I was able to get my email process to work, so I think I'm good. But i will check into your suggestion Oleg. Thanks.
MTaylorCBC

Re: Integration with ServiceNow

Post by MTaylorCBC » 2 people like this post

The following is how I was able to get "Failed" VM's to automatically create ServiceNow tickets. I did have to modify company specific information in this post. I just learned to spell Veeam, VMware and PowerShell two weeks ago, so take that into account should any questions come out of this.

As part of this, we did assign a specific Service Account for Veeam in which to run its services and login to the SQL database. This account was also granted access to the registry for Veeam, though this part may not have been required once the elevated privilege was setup for PowerShell.

Service Now:
Have your Service Now Admins review the functionality Email Inbound Actions

Post Script on the Backup job executes the following in a .cmd file.
Powershell.exe "start-process powershell.exe -ArgumentList '-File E:\veeam\Scripts\JobStatusCheck.ps1 -JobName """Domain Controllers"""' -verb runas

PowerShell script:

Code: Select all

 # Create ServiceNow ticket for failed job.
param($jobName)

Add-PSSnapin VeeamPSSnapin
Connect-VBRServer -server veeambr_server

foreach ($Job in Get-VBRJob -name "$jobName" | ? {$_.JobType -eq "Backup" -and $_.GetLastResult() -eq "Failed"})
{
  foreach ($failedVM in $Job.FindLastSession().GetTaskSessionsByStatus("Failed"))
    { 
      $Jobname = $job.Name
      $VMFailed = $failedVM.Name
      $From = "Veeam@companyname.com"
      $To = "whatever@service-now.com"
      $Subject = "$VMFailed Veeam Backup Failed"
      $Body = "
Description: Backup of VM $VMFailed failed in job '$Jobname'
Additional Comments: Backup of VM $VMFailed failed in job '$Jobname'
CI: Veeam Backup & Replication
Category: Software / Application
Impact: 4
Urgency: 4
Group: Server Department
Contact: 111-222-333
      "
      $SMTPServer = "your.mail.server.email.address"
      $SMTPPort = "25"
      Send-MailMessage -From $From -To $To -Subject $Subject -Body ($Body | Out-String) -SmtpServer $SMTPServer -port $SMTPPort
   }
}
Disconnect-VBRServer
Post Reply

Who is online

Users browsing this forum: oscarm and 20 guests