When using Service Manager, you can use the out-of-the-box Powershell-SnapIn “smcmdletsnapin” to get access to a bunch of Powershell cmdlets. These can be used to display and change different objects within the Service Manager Infrastructure. If this is not enough, you can use the famous smlets for even more cmdlets and possibilities. If you want to go a step further, you can access Service Manager by using the SDK. This can be done programmatically or of course by using Powershell. In this blog post I will show you how to use Powershell to use the Service Manager SDK.
Lets start by creating the connection to the Service Manager Management Group. First, we need a reference to the EnterpriseManagement Core dll and then create the connection. In this example I will create a connection to the local SM SDK Service with means that everything is run on the Service Manager Server itself.
Add-Type -path ‘C:\Program Files\Microsoft System Center\Service Manager 2010\SDK Binaries\Microsoft.EnterpriseManagement.Core.dll’;
$NS = “Microsoft.EnterpriseManagement”;
$EMGType = “$NS.EnterpriseManagementGroup”;
$EMG = new-object $EMGType localhost;
Now lets take a look at the possibilities. Just enter the following two commands to get an overview about the objects, properties and methods.
$EMG
$EMG | get-member
Now let’s make some examples. First we want to get some information from our Management Group. Here we go …
$EMG.isconnected | Shows if you are still connected to the Management Group |
$EMG.reconnect() | Reconnects you to the Management Group |
$EMG.Version | Shows the SM Version number |
$EMG.getconnectedusernames() | Shows the actual connected users |
$EMG.name | Shows the name of the Management Group |
$EMG.managementpacks | gm | Displays details about the ManagementPackManagement object |
$EMG.managementpacks.getmanagementpacks() | Outputs a list of all installed Management Packs |
$EMG.entitytypes.getclasses() | Displays al available classes |
$EMG.entitytypes.getclass(“a604b942-4c7b-2fb2-28dc-61dc6f465c68”) | Displays information for a specific class, referenced by the class GUID |
$EMG.connectorframework.getconnectors() | Displays information about the configured connectors |
If you want more information about the Service Manager SDK, just download the SDK documentation here. And of course read the second part of the article that will be available shortly.
regards
Marcel