Posts tagged ‘OpsMgr’

Create subscribers from .CSV

Here is a small powershell script for creating multiple subscribers from a CSV-file.

Your file should look like this:

"Name","Email","SMS","IM"
"Marsellus Wallace","marsellus.wallace@opsmode.com","12345678","marsellusw"

And the code looks like this:

$NotificationSubscribers = Import-Csv "D:\temp\SCOMNotificationSubscribers.csv"

foreach($NotificationSubscriber in $NotificationSubscribers)
{
$Name = $NotificationSubscriber.Name
$eMail = $NotificationSubscriber.Email
$SMS = $NotificationSubscriber.SMS
$IM = $NotificationSubscriber.IM

Add-SCOMNotificationSubscriber -Name $Name -DeviceList $eMail,"sms:$SMS","sip:$IM"
}

Creating a xplat script monitor from the console, System Center 2012 Operations Manager

Announced in the Technet forum last week was the new ability to create a UNIX/Linux Shell Command Monitor. Download the file from here, run it and after importing the file called Microsoft.Unix.ShellCommand.Library.mpb you will be able to create a two and/or three state UNIX/Linux script monitor from within the Operations Manager console.

image

To create a monitor simply start the Create a Unit monitor wizard.

Make your choices:

image

Give the monitor a Name select Monitor target and choose if it will be enabled.

Select how often your script will run on the agent.

In the Shell Command details you need to provide your command or path to binary/script without line breaks. So my little script that checks if a file exists.

#!/bin/bash
if ! [ -f /tmp/OPSMGR.SE ];
then
echo "Error"
else
echo "OK"
fi

Needs to be put in a file on the agent or as a one-liner. Otherwise it wont be possible to continue the wizard and a red exclamation will show, like in this picture

image

Putting the script in one line makes it look like this, I removed #!/bin/bash so the line wont be marked as a comment..

if ! [ -f /tmp/OPSMGR.SE ]; then echo "Error"; else echo "OK"; fi

image

Specifying the Error Expression

image

Specifying the Healthy Expression

image

Finish the wizard and your monitor is now running.

image

Download Management Packs, OpsMgr 2007 and 2012 Beta

One nice features is the possibility to download MP’s from the Catalog in the OpsMgr Console.
I really like being able to download MP’s to disk, that way I can back up the actual .MP file. Not having to download a .MSI, installing it and remove it from Programs and Features / Add/Remove programs if I don’t want it there. What you don’t get when you download it from the Console is the Management Pack Guide, and that one needs to be read before importing the MP.
So, to get hold of the guide document from the Console you do as follows.

Go to Administration, right click Management Packs (you can right click anywhere) and chose Download Management Packs.

Chose your download location and then click Add

Search for the MP you want to download, and select it in the list. Then click Properties

image

And there you have it!

image

A nice feature here would be to right click and Save As, but that doesn’t work. How ever you can click it and it will open in Word, if you don’t have Word installed you can mark it and copy the the link with Ctrl+C and paste it in a browser to open it on another machine.

Scheduling OpsMgr PowerShell scripts

When scheduling an Operations Manager PowerShell script you have to load the powershell snapins.

Insert this in the beginning of your script

$ServerName = “hostname”
add-pssnapin “Microsoft.EnterpriseManagement.OperationsManager.Client”;
set-location “OperationsManagerMonitoring::”;
new-managementGroupConnection -ConnectionString:$ServerName;
set-location $ServerName;