Thursday 19 July 2007

More about Property bags and Varant types

When returning values in a property bag that are not string values you will have to break open the XML of the management pack to be able to compare the values correctly.

The XML generated by the Authoring console will look something like:

<Value Type="String">7</Value>

If returning Integer values that you want to compare with integers you will have to change it to:

<XPathQuery Type="Integer">Property[@Name='Status']</XPathQuery>
<Value Type="Integer">7</Value>

Note that the Type declaration has to be on both sides of the expression. Also be aware that some version of the Authoring console may strip the Type="Integer" from the XPath query.

Thanks to Alexandre Coelho for this fix.

Wednesday 18 July 2007

Passing an Event Description to an Alert description

Finding the correct Data Item Context Parameters to use in Operations manager can be a problem. Here is the one to pass an Event description to an Alert. Useful if you want the Alert description to contain the Event description.


Tuesday 17 July 2007

Export a Sealed MP

Export a Sealed MP

A sealed MP can be exported to an XML file using Command Shell.
Find the correct name of the MP you want to export using:

get-managementpack | where {$_.Name -like "*Server.2003"}

Export using:

get-managementpack | where {$_.Name -eq "Microsoft.Windows.Server.2003"} | export-managementpack -path C:\MP

Monday 16 July 2007

Property bags and Variant Types

When using script based monitors the name value pairs get returned in what is called a propert bag. A property bag is simply a blob of XML that looks like this:

<DataItem type="System.PropertyBagData" time="2007-07-16T23:10:53.1294962+01:00" sourceHealthServiceId="8FD1B472-1464-691B-9BF7-E3AC669C2310">
<Property Name="scan.dat" VariantType="3">19</Property>
<Property Name="names.dat" VariantType="3">19</Property>
<Property Name="clean.dat" VariantType="3">19</Property>

The XML describes that this is a property bag, that date/time that it was submitted to the management server and the properties contained in the property bag.

The VariantType describes the type of the value that is returned. The variant types are:

Empty = 0
Null = 1
Short = 2
Integer = 3
Single = 4
Double = 5
Currency = 6
Date = 7
String = 8
Object = 9
Error = 10
Boolean = 11
Variant = 12
DataObject = 13
Decimal = 14
Byte = 15
Char = 16
Long = 17

Clearing the Operation Manager Console Cache

When creating and deleting management packs you may find that the console becomes out of sync with the database. To fix this you can delete the Console cache by deleting the files under
C:\Documents and Settings\username\Local Settings\Application Data\Microsoft\Microsoft.Mom.UI.Console

Friday 13 July 2007

Some Ops manager Agent Stuff

We had some problems every time we built a new management group in our lab. All the old agents would still be trying to report to the old management group. This was a pain because all this did was clutter up the Operations Manager Log. The solution we used was to create a task that would completely uninstall all the agents. They would then be automatically reinstalled by the active management group if you have applied the overrides to enable the recoveries as detailed in the System Center Management Pack Guide. A bit of powershell would then run this task against all agents.

To Create the Uninstall Task

On the Authoring pane on the console create a new command line agent task called CompleteUninstall. The target is Windows Computer. The command line settings are shown below.

Uninstall command for Agent (RTM)

MsiExec.exe /x {E7600A9C-6782-4221-984E-AB89C780DC2D} /quiet

This gives us a task that ca be run on an agent to perform an uninstall of an agent. To run this on all agents the easiest way is to do it in a powershell script

Powershell Script to run the task for all agents

$uninstallTask = get-task | where {$_.Name -eq "CompleteUninstall"}
foreach($agent in get-agent)
$server = $agent.Displayname
start-task -asynchronous -task:$uninstallTask -path .\Microsoft.SystemCenter.AgentManagedComputerGroup\$server

Save this script as a .ps1 file and then run it from the Operations Manager Command Shell. The results of these tasks will always show in the Operations Console under Task Status as failed as the Agent has been removed.

Thursday 12 July 2007

Operation Manager Command Shell on any system

This is a basic guide to get a Operations Manager Command shell on any system without having to install the UI components. You will need to have Powershell and DotNet 3.0 installed on the system.

Copy the Files

You will need to copy some files from your Ops manager install to get the command shell working.

From the Ops Manager installation directory:

Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll-help.xml Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml

From the SDK Binaries Folder in the O
ps Manager installation directory:


Copy these files to a folder on the system you want the command shell on. For this example I will copy them to C:\OpsShell.

Register the Powershell Snap-in

For the Powershell snap-in to work we need to register it. As we are not installing the UI this will have to be done manually. Add the below registry settings replacing "C:\\OpsShell" in the following regsitry entries with the correct path to the files.


Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\PowerShellSnapIns\Microsoft.EnterpriseManagement.OperationsManager.Client] "ApplicationBase"="C:\\OpsShell" "AssemblyName"="Microsoft.EnterpriseManagement.OperationsManager.ClientShell, Version=6.0.4900.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" "ModuleName"="C:\\OpsShell\\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.dll" "PowerShellVersion"="1.0" "Vendor"="Microsoft Corporation" "Version"="6.0.4900.0" "Description"="Microsoft Operations Manager Shell Snapin" "Types"="C:\\OpsShell\\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Types.ps1xml" "Formats"="C:\\OpsShell\\Microsoft.EnterpriseManagement.OperationsManager.ClientShell.Format.ps1xml"


Create the Startup Script

Below is a Powershell script that you can use as a shortcut to start the Command Shell. Copy it to notepad and save it in C:\OpsShell as OpsShell.ps1. Some of the script was borrowed from here


param ($rootMS)

if ($rootMS -eq $null)
$rootMS = Read-Host "Root manangement server"

$checksnappin = Get-PSSnapin | where {$_.Name -eq "Microsoft.EnterpriseManagement.OperationsManager.Client"}
if ($checksnappin -eq $null)
add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client" -ErrorVariable errSnapin ;
Set-Location "OperationsManagerMonitoring::" -ErrorVariable errSnapin ;
new-managementGroupConnection -ConnectionString:$rootMS -ErrorVariable errSnapin ;
set-location $rootMS -ErrorVariable errSnapin ;


Starting the Command Shell

To start the Command Shell open powershell and run C:\OpsShell\OpsShell.ps1.

If you get the error:

File C:\OpsShell\OpsShell.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details.

Then run this command to change the execution policy:

Set-ExecutionPolicy Unrestricted

This works for me on XP SP2 and Server 2003 SP2

This could be expanded to offer the ability for our server admins to do things such as set Maintenance Mode on or off without having to do it in 3 different locations in the console as is currently needed.