Skip to content
adatum
  • Home
  •  About adatum
  •  Learn Azure Bicep
  •  SCOM Web API
Operations Manager

SCOM 2016 migration – Transfer alert Ticket ID

  • 12/06/201707/01/2025
  • by Martin Ehrnst

Quick publish:

We are migrating a large SCOM environment to 2016 and the current 2012 environment have an integration with our ticketing system. As we want the migration as smooth as possible, updating the co-existing alerts with the already connected ticket ID seemed like a good idea.

All alerts with an assigned ticket that aren’t closed have a custom resolution state. Using Powershell I grabbed all alerts from SCOM 2012 and updated the same alerts in our 2016 environment.

Import-Module OperationsManager

#Connect to old SCOM environment
$OldEnv = New-SCOMManagementGroupConnection OldScomServer

#Get all alerts with custom resolution state, indicating a ticket is created
$Alerts = get-scomalert | where {$_.ResolutionState -eq 3}
#Connect to the new SCOM Environment.
$NewEnv = New-SCOMManagementGroupConnection NewSCOMServer

#Loop through the alert and set resolution state, ticket and custom field in the new environment
foreach ($Alert in $Alerts)
    {
    Get-ScomAlert | where {$_.Name -eq $Alert.Name -and $_.MonitoringObjectPath -eq $Alert.MonitoringObjectPath -and $_.ResolutionState -eq 0} | Set-SCOMAlert -ResolutionState 3 -CustomField4 "TEXT" -TicketID $Alert.TicketId
    }
#list updated alerts
Get-SCOMAlert -ResolutionState 3 | select Name, TicketID

As you see, we have a string in custom field 4, you can just remove this and change your resolution state to fit your environment.

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
Automation

Update: SCOM web API

  • 02/06/201707/01/2025
  • by Martin Ehrnst

Big updates:

I have made a lot of changes to the SCOM web API. As you can see from the picture above. Maintenance scheduling is added, which means you can create a new maintenance schedule in SCOM 2016. To the computer endpoints I have added the a possibility to get detailed information. This will list all related object to the server. Logical disks, network cards etc.

These are the API endpoints available at the moment:

Agents

Route Description
[GET] API/Agents Gets all agents
[GET] API/Agents/{id} Get a single agent

Alerts

Route Description
[GET] API/Alerts Gets all open alerts
[GET] API/Alert/{id} Get a single alert
[PUT] API/Alert Update the specified alert with resolution state, TicketId
[GET] API/Alert/{ComputerName} Get all alert from specific computer, use IncClosed=true to include open and closed alerts

Computer

Route Description
[GET] API/Computer/Windows Get all windows computers wit basic properties
[GET] API/Computer/Windows/{ComputerName} Get A single windows computers with basic properties
[GET] API/Computer/Windows/{ComputerName}/Detailed Get A single windows computers with hosted child objects
—— ——
[GET] API/Computer/Linux Get all Linux computers wit basic properties
[GET] API/Computer/Linux/{ComputerName} Get A single Linux computer with basic properties
[GET] API/Computer/Linux/{ComputerName}/Detailed Get A single Linux computers with hosted child objects

Maintenance

Route Description
[POST] API/ComputerMaintenance Put the specific computer object and all child in maintenance mode
[POST] API/ObjectMaintenance Put the specific monitoring object and all child in maintenance mode
[POST] API/MaintenanceSchedule Create a new maintenance schedule. SCOM 2016 ONLY

Object

Route Description
[GET] API/MonitoringObject/{id} Get a monitoring object and all child object

 

Examples

Create a new maintenance schedule by sending a post to /API/MaintenanceSchedule with a body including object id, start date and end date in UTC, optionally a comment.

#CREATE A MAINTENANCE SCHEDULE WITH TWO OBJECTS. Time in UTC

$body = @"
{
  "scheduleName": "new maintenance schedule",
  "id": "a43a5b09-5c32-8624-1427-73b8e1f05248",
  "StartTime": "2017-05-30T13:53:33.550Z",
  "EndTime": "2017-05-30T14:53:33.550Z",
  "comment": "TicketID"
}
"@


Invoke-RestMethod -Uri 'http://localhost:64049/API/MaintenanceSchedule' -Method Post -Body $body -UseDefaultCredentials -ContentType 'Application/json'

Get details/related object from a computer:

Invoke-RestMethod -Uri 'https://host/API/Computer/windows/computer.fqdn/Detailed' -UseDefaultCredentials

Which will return something like this. Notice the relatedObjectsCount and relatedObjects

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
Automation

Web API for System Center Operations Manager

  • 05/05/201707/01/2025
  • by Martin Ehrnst

The SCOM web API is updated, see this post

You will always find the latest SCOM Web API release on GitHub

 

System Center Operations Manager (SCOM) is a widely used monitoring platform and one of its advatages is the ability to custom author monitoring through management pack development.
With a ‘cloud first’ approach most systems is able to do information exchange or integration through a web-based API, often reffered to as a REST API. SCOM have many ways to exchange information and the System Center Suite also have an integration platform call System Center Service Provide Foundation (SPF) which you can read more about here

To support a more light weight integration platform i decided to start my first C# project and develop a web-based API for SCOM that supported the daily used “functions”. Thanks to my colleague @RudiMartinsen i managed to create a working solution.

API Endpoints

  • [GET] Agents (Admin privileges required)
    • Get all agents
    • single based on Guid
  • [GET] Alerts
    • Gets all alerts
    • single based on Guid
    • Single based on ComputerName
      • Include ‘closed’ with IncClosed=true
  • [PUT] Alerts
    • Update a single alert with resolution state and/or ticket id
    • Monitor generated alerts will be resett if 255 (closed) is sent as resolution state
  • [GET] WindowComputers
    • Get all partial monitoring object from the Windows Computer class
    • Single based on ComputerName
  • [POST] ComputerMaintenance*
    • Maintenance mode a Windows Computer for a specific # minutes
  • [GET] MonintoringObject/{id}
    • Get a single monitoring object based on ID (Guid)

I have uploaded the source project on GitHub and hopefully our community can continue to develop and introduce new features missing in this release.

 

Installation

There are two versions of the API. One without user impersonation and one where this is available. To install the version with user impersonation enabled. Do the following on a SCOM Management server

  • Download the project or .zip file from GitHub
  • Copy the required .dll from your management server (\Operations Manager\Server\SDK Binaries) to the web api Bin folder
    • Microsoft.EnterpriseManagement.Core.dll
    • Microsoft.EnterpriseManagement.OperationsManager.dll
    • Microsoft.EnterpriseManagement.Runtime.dll
  • Create a new web site and set physical path to where you extracted the files

  • Enable windows authentication (and basic if you want)
  • Set your Application pool to use network service identity

 

Examples

Using powershell here are a few examples on how you can use the API

Get Alerts
#Get all alerts
Invoke-RestMethod -Uri 'http://localhost:64049/Api/alerts' -UseDefaultCredentials

#Get a single alert
Invoke-RestMethod -Uri 'http://localhost:64049/Api/alerts?id=4a6f29e3-f4b5-4883-a3f2-97eb3be50c12' -UseDefaultCredentials

#Get alerts specified with computername
Invoke-RestMethod -Uri 'http://localhost:64049/Api/alerts?ComputerName=COMPUTERNAME.fqdn' -UseDefaultCredentials
Put a computer in to maintenance
PS C:\Users\...> $json = @"
{
    "DisplayName": "COMPUTERNAME.fqdn",
    "Minutes": 10,
    "comment": "I believe this is working"
}
"@

Invoke-RestMethod -Method POST -Uri 'http://localhost:64049/API/ComputerMaintenance' -Body $json -UseDefaultCredentials -ContentType 'Application/json'

Returns

DisplayName           Minutes EndTime                      comment                  
-----------           ------- -------                      -------                  
COMPUTER NAME.fqdn      10 2017-05-05T08:42:56.5938294Z I believe this is working
Get a monitoring object
#Get a monitoring object
Invoke-restmethod -uri 'http://localhost:64049/API/MonitoringObject/cb191c1a-47dc-3c51-3686-9f66dd59f187' -UseDefaultCredentials


displayName : D:
healthState : Success
inMaintenance : False
stateLastModified : 23.03.2017 15.39.23
classes :
path : MyComputerHostingThisDisk.fqdn

 

Limitations*

  • SCOM .dll files will need to copied manually in to the web api application folder as I assume im not allowed to redestribute these.

Share this:

  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit

Posts pagination

1 2 3 4 5 … 7

Popular blog posts

  • Azure Application registrations, Enterprise Apps, and managed identities
  • Windows Admin Center with SquaredUp/SCOM
  • Microsoft killed SCOM internally
  • Creating Azure AD Application using Powershell
  • Azure token from a custom app registration

Categories

Automation Azure Azure Active Directory Azure Bicep Azure DevOps Azure Functions Azure Lighthouse Azure Logic Apps Azure Monitor Azure Policy Community Conferences CSP Monitoring DevOps GitHub Guest blogs Infrastructure As Code Kubernetes Microsoft CSP MPAuthoring OMS Operations Manager Podcast Powershell Uncategorised Windows Admin Center Windows Server

Follow Martin Ehrnst

  • X
  • LinkedIn

RSS feed RSS - Posts

RSS feed RSS - Comments

Microsoft Azure MVP

Martin Ehrnst Microsoft Azure MVP
Adatum.no use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it. Cookie Policy
Theme by Colorlib Powered by WordPress