In my early days of monitoring we had a dedicated computer set up who read out all the critical alerts as for example a server was down. It was a fairly simple setup but had it’s flaws and it was not combined with System Center Operations Manager (which is already a big flaw).
The idea to create a PowerShell script for just doing that was already a significant time on my to do list but kind of made it to the top of my list due to a Facebook request I got last week.
SCOM 2007 (will post the SCOM 2012 version shortly)
*UPDATE* The SCOM 2012 script is now available here: http://gallery.technet.microsoft.com/SCOM-2012-Speak-script-9f24b90c
The pc you want to read out the alert on needs to have:
WinRM needs to be enabled
At least .net framework 3.0 needs to be installed
PowerShell 2.0 needs to be installed
Speakers (pretty obvious no?)
First of all make sure that Computer has PowerShell 2.0 installed.
If this is not the case download and install it here: http://support.microsoft.com/kb/968930
Open PowerShell by browsing to Start > Accessories > Windows Powershell and open Powershell as administrator by right clicking and choosing run as admin:
Next thing on our list is to enable the ability remotely execute commands on the computer.
Run: “Enable-PSRemoting –Force” to enable the WinRM service on the computer.
An alternative way is to use the command WinRM quickconfig in an elevated prompt.
Verify afterwards that the service was started:
Now test from the RMS that the server is reachable through WinRM by running the following command on the RMS:
Test-WsMan COMPUTER (replace COMPUTER with the name of the computer you want the alert to be played on)
The following should appear:
In this example I’m using this script to read out a warning when there’s a server down but you can easily change it to your specific needs of course.
The 2007 script can be downloaded here
The 2012 script can be downloaded here
Copy paste of the script for your reference
#=========================================================================
# AUTHOR: Dieter Wijckmans
# DATE: 07/08/2012
# Name: speak_scom2007.PS1
# Version: 1.0
# COMMENT: Let SCOM read an alert out loud on a remote computer to notify the operator
# CREDITS:
# Usage: .\speak_scom2007.ps1 -$severity -$text -$pc1 -$machine
#
#=========================================================================
###Prepare environment for run###
####
# Start Ops Mgr snapin, get RMS
###
###
#Get parameters from command line, Start Ops Mgr snapin
###
param ([string]$severity,[string]$stext,[string]$pc1,[string]$machine)
#param ([string]$text,[string]$pc1)
##Read out the RMS name
$objCompSys = Get-WmiObject win32_computersystem
$rootMS = $objCompSys.name
#If the RMS is installed on a cluster comment the above 2 lines, uncomment the line below and fill in the server below.
#$rootMS = “Your clustered RMS here”
#Initializing the Ops Mgr 2007 Powershell provider#
Add-PSSnapin “Microsoft.EnterpriseManagement.OperationsManager.Client” -ErrorVariable errSnapin ;
Set-Location “OperationsManagerMonitoring::” -ErrorVariable errSnapin ;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin ;
Set-Location $rootMS -ErrorVariable e-severrrSnapin ;
#Set Culture Info# In this case Dutch Belgium
$cultureInfo = [System.Globalization.CultureInfo]’nl-BE’
#Error handling setup
$error.clear()
$erroractionpreference = “SilentlyContinue”
$thisScript = $myInvocation.MyCommand.Path
$scriptRoot = Split-Path(Resolve-Path $thisScript)
$errorLogFile = Join-Path $scriptRoot “error.log”
if (Test-Path $errorLogFile) {Remove-Item $errorLogFile -Force}
#create the text to read. You can change this section to read out a different phrase
#Notice the extra spaces in the string. These are used to slow down the reading and make it more comprehensive
$text = $severity + ” Alert on ” + $machine + ” ” + $stext
#execute script#
invoke-command -computer $pc1 -scriptblock {[Reflection.Assembly]::LoadWithPartialName(“System.Speech”)
$voice = New-Object System.Speech.Synthesis.SpeechSynthesizer
$voice.Speak($args[0]) } -argumentlist $text
###
#Remove the Ops Mgr PSSnapin#
###
Remove-PSSnapin Microsoft.EnterpriseManagement.OperationsManager.Client
You can change the actual change the sentence SCOM is speaking out loud in the highlighted section so let your imagination + creativity go wild on this…
The last thing you have to do to let the computer read out the SCOM alerts is to make a subscription for the alert and pass the desired parameters.
For a full list of all the available parameters I would like to reference to a great post of Kevin Holman: http://blogs.technet.com/b/kevinholman/archive/2007/12/12/adding-custom-information-to-alert-descriptions-and-notifications.aspx
In my particular example I’m using the following parameters: Severity, Machine name, pc1 and text.
Severity: Alert severity
Machine name: machine which is down
Text: Free text you would like to read out loud.
Pc1: The machine where the text needs to be spoken.
: You can send the command to multiple PC’s at the same time by adding a new variable to the command line and C/P the speak section in the script with the name of the new parameter.
The Notification Channel should look like this:
Full Path of the command file: C:\Windows\System32\WindowsPowerShell\V1.0\Powershell.exe
Command Line Parameters:
C:\Scripts\speak_scom2007.ps1 -severity ‘$Data/Context/DataItem/Severity$’ -stext ‘Machine Down’ -pc1 ‘desktop1’ -machine ‘$Data/Context/DataItem/ManagedEntityDisplayName$’
Startup folder for the command line:
C:\scripts
Only thing left to do is link this channel to a subscriber and make an actual subscription for the machine down alerts.
Now just wait until SCOM will start talking to you