Udostępnij za pośrednictwem


How to update custom alert fields using command line notification and PowerShell

In previous blog link, we discussed about the extending windows computer class, registry based discovery and creating views.

In this blog post, I'll discuss on how to update the alert custom fields based on the extended windows computer class properties.

 

Please refer below blog for the steps to create the command line notification to run PowerShell script.

https://blogs.msdn.com/b/steverac/archive/2010/08/17/updating-custom-alert-fields-using-subscriptions-and-powershell.aspx

 

I wrote small PowerShell script for our scenario from previous blog link, you can use this script along with the steps mentioned in above blog.

 

Param(

[parameter(mandatory=$true)][GUID] $alertID

)

Import-Module OperationsManager;

$alertID = $alertID.toString();

$newAlert = Get-SCOMAlert -Criteria "Id = '$alertID'";

$srv= $newAlert.PrincipalName;

$class = Get-SCOMClass -Name 'ExtendedWindowsComputer';

 

If (!$newAlert.CustomField1 -AND !$newAlert.CustomField2)

{

$objClass= Get-SCOMClassInstance -Class $class | Where-Object{$_.'[Microsoft.Windows.Computer].PrincipalName' -like "$srv"}

$app = ($objClass).'[ExtendedWindowsComputer].ServerType'

$srvType=($objClass).'[ExtendedWindowsComputer].Application'

$newAlert.CustomField1=$srvType;

$newAlert.CustomField2=$app;

$newAlert.Update("")

}

Note: Test this in your lab first and make necessary changes according to your environment.

 

Enjoy!

Comments

  • Anonymous
    November 30, 2014
    This is the first of five part blog series about the System Center Operations Manager 2012 - Management