Home » Microsoft Operations Manager 2005 » Count number of instances

Contoso.se

Welcome to contoso.se! My name is Anders Bengtsson and this is my blog about Azure infrastructure and system management. I am a senior engineer in the FastTrack for Azure team, part of Azure Engineering, at Microsoft.  Contoso.se has two main purposes, first as a platform to share information with the community and the second as a notebook for myself.

Everything you read here is my own personal opinion and any code is provided "AS-IS" with no warranties.

Anders Bengtsson

MVP
MVP awarded 2007,2008,2009,2010

My Books
Service Manager Unleashed
Service Manager Unleashed
Orchestrator Unleashed
Orchestrator 2012 Unleashed
OMS
Inside the Microsoft Operations Management Suite

Count number of instances

This script checks if notepad.exe is running more that 4 times. If it is running more than 4 times a event is generated. You can then collect those event and get an alert in operators console.


strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set objShell = CreateObject("Wscript.Shell")
Set colProcesses = objWMIService.ExecQuery _
("Select * from Win32_Process Where Name = 'notepad.exe'")
If colProcesses.Count < 4 Then Const EVENT_WARNING = 2 Set objShell = CreateObject("Wscript.Shell") objShell.LogEvent EVENT_WARNING, _ "There are less then 4 instances of notepad.exe running" End If


1 Comment

Comments are closed.