Answered by:
The 'ID' attribute is invalid when inserting new Group

Question
-
Hi All,
Hope you can offer some advice with a problem I have. I have just installed SCOM 2007 R2 to monitor our test machines. As we have a number of machines each of our testers will be responsible for the machines they are using at any particular time. They will need to be notified when problems occur. Following Kevin Holman's blog on subscriptions and groups - http://blogs.technet.com/kevinholman/archive/2008/02/01/configuring-notifications-to-include-specific-alerts-from-specific-groups-and-classes.aspx - I am trying to create a script that will configure the group and the subscription for each machine. If a group for a particular machine does not exist the script should create a new group. Below is an except from my script just for creating the group.
Unfortunately I am hitting an error when trying to do this. When InsertCustomMonitoringObjectGroup($group) is called in the script below I get the error
Exception : System.Management.Automation.MethodInvocationException: Exception calling "InsertCustomMonitoringObjectGroup" with "1" argument(s
): "Processing the template failed. See inner exception for details." ---> : Processing the template failed. See inner exception
for details.
XSD verification failed for management pack. [Line: 1, Position: 1921]The 'ID' attribute is invalid - The value 'ESTEST.TST-2K85S
1 Group' is invalid according to its datatype 'ManagementPackUniqueIdentifier' - The Pattern constraint failed.The Pattern constr
aint failed.The XML in the $formula is taken from the export of the ESTEST management pack after creating a Group through the Ops Mgr Console GUI. I've tried various formats and values for namespace and groupName but all generate the same error.
I'd be very gratefull for any sugestions as to what I need to change to get this working.
function CreateGroup($Agent) { $ind = $Agent.Name.ToUpper().indexof(".") if ($ind -lt 1) { $ind = $Agent.Name.ToUpper().length } $aName = $Agent.Name.ToUpper().substring(0, $ind) $groupName = $aName + " Group" $groupDisplayName = $aName + " Group" $formula = '<MembershipRule>' + '<MonitoringClass>$MPElement[Name="Windows!Microsoft.Windows.Computer"]$</MonitoringClass>' + '<RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>' + '<Expression>' + '<RegExExpression>' + '<ValueExpression>' + '<Property>$MPElement[Name="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</Property>' + '</ValueExpression>' + '<Operator>MatchesWildcard</Operator>' + '<Pattern>(' + $aName + '*|' + $aName.toLower() + '*)</Pattern>' + '</RegExExpression>' + '</Expression>' + '</MembershipRule>' + '<MembershipRule>' + '<MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.HealthServiceWatcher"]$</MonitoringClass>' + '<RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>' + '<Expression>' + '<RegExExpression>' + '<ValueExpression>' + '<Property>$MPElement[Name="System!System.Entity"]/DisplayName$</Property>' + '</ValueExpression>' + '<Operator>MatchesWildcard</Operator>' + '<Pattern>(' + $aName + '*|' + $aName.toLower() + '*)</Pattern>' + '</RegExExpression>' + '</Expression>' + '</MembershipRule>' write-host $formula $group = New-Object Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup($namespace,$groupName,$groupDisplayName,$formula) $mp.InsertCustomMonitoringObjectGroup($group) Resolve-Error } function Resolve-Error ($ErrorRecord=$Error[0]) { $ErrorRecord | Format-List * -Force $ErrorRecord.InvocationInfo |Format-List * $Exception = $ErrorRecord.Exception for ($i = 0; $Exception; $i++, ($Exception = $Exception.InnerException)) { "$i" * 80 $Exception |Format-List * -Force } } $RMS = "tst-mon.mycomp.com" $namespace = "ESTEST" $CompName = "tst-2k85s1" Set-Location Monitoring:\$RMS $mp = Get-ManagementPack -name $namespace $Agent = $null foreach($agenta in Get-Agent) { if($agenta.ComputerName.ToUpper().StartsWith($CompName.ToUpper())) { $Agent = $agenta break } } if($Agent -ne $null) { CreateGroup($Agent) }
Many thanks
Andrew
Monday, April 26, 2010 9:49 AM
Answers
-
PSS was able to identify syntax issues with my script. The following script works in creating an empty group:
$rmsServerName = 'localhost'; add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString $rmsServerName; set-location $rmsServerName; $mpName = 'test' $namespace = 'test' $groupName = '192.168.10.198_1' $groupDisplayName = '192.168.10.198_1' $formula = '<MembershipRule>' + '<MonitoringClass>$MPElement[Name="nworksVMwareVEM550415!nworks.VMware.VEM.VMHOST"]$</MonitoringClass>' + '<RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>' + '<Expression>' + '<SimpleExpression>' + '<ValueExpression>' + '<Property>$MPElement[Name="nworksVMwareVEM550415!nworks.VMware.VEM.VMHOST"]/id$</Property>' + '</ValueExpression>' + '<Operator>Equal</Operator>' + '<ValueExpression>' + '<Value>192.168.10.198</Value>' + '</ValueExpression>' + '</SimpleExpression>' + '</Expression>' + '</MembershipRule>' $group = New-Object Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup($namespace,$groupName,$groupDisplayName,$formula) $mp = Get-ManagementPack -name $mpName $mp.InsertCustomMonitoringObjectGroup($group)
- Marked as answer by Marco Shaw Monday, July 19, 2010 1:27 PM
Friday, June 11, 2010 1:30 PM
All replies
-
Hi there,
Any luck? I am trying something similar to this and am getting exception errors as well. For simplicity sakes, here is my script to just add an empty group to a "test" management pack.
$rmsServerName = 'localhost'; add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString $rmsServerName; set-location $rmsServerName; $mpName = 'test' $namespace = 'test' $groupName = 'test2' $groupDisplayName = 'test2' $formula = @" <MembershipRule> <MonitoringClass>$MPElement[Name="SystemCenter!Microsoft.SystemCenter.AllComputersGroup"]$</MonitoringClass> <RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass> <Expression> <SimpleExpression> <ValueExpression> <Value>True</Value> </ValueExpression> <Operator>Equal</Operator> <ValueExpression> <Value>False</Value> </ValueExpression> </SimpleExpression> </Expression> </MembershipRule> "@ $group = New-Object Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup($namespace,$groupName,$groupDisplayName,$formula) $mp = Get-ManagementPack -name $mpName $mp.InsertCustomMonitoringObjectGroup($group)
Error:
Exception calling "InsertCustomMonitoringObjectGroup" with "1" argument(s): "The element 'MembershipRules' has invalid child element 'MembershipRules'. List of possible elements expected: 'Memb
ershipRule'."
At C:\Documents and Settings\brianp\Desktop\Create Groups.ps1:36 char:38
+ $mp.InsertCustomMonitoringObjectGroup <<<< ($group)
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodExceptionPlease note, my group does get created. I get all sorts of errors when trying to view the properties of the group. So, something is clearly wrong with it.
Friday, May 21, 2010 3:15 AM -
Hi vbpav,
No, unfortunately I haven't got any further with this.
I was hoping that there was enough expertise in this forum to be able to help with this problem but I guess it is an area that hasn't been used much, not even by Microsoft.
If I do find a solution I'll post it here for you and others to see how it should be done.
Sorry I can't help at the moment :(
Andrew
Friday, May 21, 2010 8:44 AM -
No worries. I have opened up a PSS case on this. I will post the results here.
Regards,Brian
Friday, May 21, 2010 6:34 PM -
PSS was able to identify syntax issues with my script. The following script works in creating an empty group:
$rmsServerName = 'localhost'; add-pssnapin "Microsoft.EnterpriseManagement.OperationsManager.Client"; set-location "OperationsManagerMonitoring::"; new-managementGroupConnection -ConnectionString $rmsServerName; set-location $rmsServerName; $mpName = 'test' $namespace = 'test' $groupName = '192.168.10.198_1' $groupDisplayName = '192.168.10.198_1' $formula = '<MembershipRule>' + '<MonitoringClass>$MPElement[Name="nworksVMwareVEM550415!nworks.VMware.VEM.VMHOST"]$</MonitoringClass>' + '<RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass>' + '<Expression>' + '<SimpleExpression>' + '<ValueExpression>' + '<Property>$MPElement[Name="nworksVMwareVEM550415!nworks.VMware.VEM.VMHOST"]/id$</Property>' + '</ValueExpression>' + '<Operator>Equal</Operator>' + '<ValueExpression>' + '<Value>192.168.10.198</Value>' + '</ValueExpression>' + '</SimpleExpression>' + '</Expression>' + '</MembershipRule>' $group = New-Object Microsoft.EnterpriseManagement.Monitoring.CustomMonitoringObjectGroup($namespace,$groupName,$groupDisplayName,$formula) $mp = Get-ManagementPack -name $mpName $mp.InsertCustomMonitoringObjectGroup($group)
- Marked as answer by Marco Shaw Monday, July 19, 2010 1:27 PM
Friday, June 11, 2010 1:30 PM -
PSS was able to identify syntax issues with my script. The following script works in creating an empty group:
... $formula = '<MembershipRule>' +
Monday, July 19, 2010 1:29 PM -
Here is how we found our way around that exception:
After the new-object line put in a catch:
try
{
$mp.InsertCustomMonitoringObjectGroup($group)
}
catch [System.Exception]
{
Write-Host $_.Exception
}That will likely show you something like this:
Verification failed with [1] errors:
-------------------------------------------------------
Error 1:
: Failed to verify Discovery [MPNAME.GROUPNAME.DiscoveryRule]
Failed to verify referenced module : ID=GroupPopulationDataSourceInvalid configuration specified for Module [GroupPopulationDataSource]Cannot find MPElement: SystemCenter!Microsoft.SystemCenter.ManagedComputer specified in expression: $MPElement[Name="SystemCenter!Microsoft.SystemCenter.ManagedComputer"]$Cannot resolve identifier [SystemCenter!Microsoft.SystemCenter.ManagedComputer] in the context of ManagementPack [MPNAME]. Unknown alias [SystemCenter]
-------------------------------------------------------
Failed to verify Discovery [MPNAME.GROUPNAME.DiscoveryRule]Failed to verify referenced module : ID=GroupPopulationDataSourceInvalid configuration specified for Module [GroupPopulationDataSource]Cannot find MPElement: SystemCenter!Microsoft.SystemCenter.ManagedComputer specified in expression: $MPElement[Name="SystemCenter!Microsoft.SystemCenter.ManagedComputer"]$Cannot resolve identifier [SystemCenter!Microsoft.SystemCenter.ManagedComputer] in the context of ManagementPack [MPNAME]. Unknown alias [SystemCenter]Looking at your referenced in your MP, you'll see the Alias's don't match up well. In our case, I had to modify the $formula with MP Alias names that matched my MP:
$strMembers += '<MembershipRule><MonitoringClass>$MPElement[Name="SC!Microsoft.SystemCenter.ManagedComputer"]$</MonitoringClass><RelationshipClass>$MPElement[Name="MicrosoftSystemCenterInstanceGroupLibrary6172210!Microsoft.SystemCenter.InstanceGroupContainsEntities"]$</RelationshipClass><IncludeList>' + `
'<MonitoringObjectId>'+ $agent.ID + '</MonitoringObjectId></IncludeList></MembershipRule>'I hope this helps.
Friday, April 29, 2011 5:36 PM