Powershell script Discovery doesn't work

Hi

We have a situation to populate a group (created with in a sealed MP) with the objects already created by an unsealed Management pack (using templates like windows service).

Using a power shell discovery script with target on Rootmanagement Server.

in the script below $cis.Count confirms the the Classinstance being fetched from the Unsealed MP. Is the assignment $relationshipInstance.Target = $ci correct or is there a better way to do this.

April 20th, 2012 11:46pm

the Script is

param($sourceId,$managedEntityId,$appName)

Import-Module OperationsManager

$api = new-object -comObject 'MOM.ScriptAPI'

$discoveryData = $api.CreateDiscoveryData(0, $SourceId, $ManagedEntityId)

$ms = "Server01"

$mp = Get-SCOMManagementPack -Name "UnsealedManagementpackname" -ComputerName $ms

$C = get-ScomClass -ManagementPack $mp -ComputerName $ms

$cis = get-scomclassinstance -Class $C -ComputerName $ms

$groupInstance = $discoveryData.CreateClassInstance("$MPElement[Name='GroupID']$")

foreach ($ci in $cis)

{

$relationshipInstance = $discoveryData.CreateRelationshipInstance("$MPElement[Name='MSIL!Microsoft.SystemCenter.InstanceGroupContainsEntities']$")

$relationshipInstance.Source = $groupInstance

$relationshipInstance.Target = $ci

$discoveryData.AddInstance($relationshipInstance)

}

$discoveryData

Free Windows Admin Tool Kit Click here and download it now
April 20th, 2012 11:47pm


Hi,

I would like to share the following with you for your reference:

How to Create Discovery Data by Using a Script
http://msdn.microsoft.com/en-us/library/bb437613.aspx

Scripting Relationship Discovery in Operations Manager 2007 / 2012
http://matthewlong.wordpress.com/2012/03/03/scripting-relationship-discovery-in-operations-manager-2007-2012/

Seed Based Discovery Concepts
http://blogs.technet.com/b/authormps/archive/2011/02/25/seed-based-discovery-concepts.aspx

Hope this helps.

Thanks.

April 26th, 2012 9:36am

Hi Habeeb,

I observered that $C = get-ScomClass -ManagementPack $mp -ComputerName $ms returns always $null if run this script inside management pack powershell timed discovery workflow. It works fine from poweshell console.

Regards,

Kishun

Free Windows Admin Tool Kit Click here and download it now
August 16th, 2012 6:00am

Hello!

I guess it should looks like this: $relationshipInstance.Target($ci)

July 2nd, 2015 7:22am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics