how to create a dependency monitor for an group using powershell ?
$mpName = 'TESTMP' $ManagementServer="sc2012om01" $namespace = $mpName $mp = Get-SCOMManagementPack -name $mpName -ErrorAction Stop -ComputerName $ManagementServer $mg=Get-SCOMManagementGroup -ComputerName $ManagementServer $mc=$mg.GetMonitoringClass($group.Id) $omonitor1=Get-SCOMMonitor -displayName test -ComputerName $ManagementServer $MPApublic=[Microsoft.EnterpriseManagement.Configuration.ManagementPackAccessibility]::Public $newmonitor=New-Object microsoft.EnterpriseManagement.Configuration.ManagementPackdependencymonitor($mp,[Guid]::NewGuid().Tostring().Replace("-",""),$MPApublic) $newmonitor.DisplayName="test2" $newmonitor.Category=[Microsoft.EnterpriseManagement.Configuration.ManagementPackCategoryType]::Custom $newmonitor.MemberUnAvailable=[Microsoft.EnterpriseManagement.Configuration.HealthState]::Error $newmonitor.membermonitor = ? $newmonitor.Target= ? $newmonitor.relationshiptype ? How to set membermonitor\target\relationshiptype properties ,because these properties were type of Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference`1 ,But i do not know how to create it with powershell PS desktop:\> $omonitor1.ParentMonitorID.GetType().FullName Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference`1[[Microsoft.EnterpriseManagement.Configuration.ManagementPackAggregateMonitor, Microsoft.EnterpriseManagement.Core, Ver sion=7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] PS desktop:\> $omonitor1.Category.GetType().fullname Microsoft.EnterpriseManagement.Configuration.ManagementPackCategoryType PS desktop:\> $omonitor1.MemberMonitor.GetType().FullName Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference`1[[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor, Microsoft.EnterpriseManagement.Core, Version=7.0. 5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] PS desktop:\> $omonitor1.RelationshipType.GetType().FullName Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference`1[[Microsoft.EnterpriseManagement.Configuration.ManagementPackRelationship, Microsoft.EnterpriseManagement.Core, Version =7.0.5000.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]] yoke88 IMyoke-msn@hotmail.com
September 12th, 2012 9:51am

$mpName = 'TESTMP' $ManagementServer="sc2012om01" $namespace = $mpName $mp = Get-SCOMManagementPack -name $mpName -ErrorAction Stop -ComputerName $ManagementServer $mg=Get-SCOMManagementGroup -ComputerName $ManagementServer $baseMemberMonitor=Get-SCOMMonitor -ComputerName $ManagementServer -DisplayName '' $baseRelationship=Get-SCOMRelationship -Id fdd1eeb6-e022-761c-58f1-8afd88ffaa88 -ComputerName $ManagementServer $baseParentMonitor=Get-SCOMMonitor -computername $ManagementServer -Id a6c69968-61aa-a6b9-db6e-83a0da6110ea $MPApublic=[Microsoft.EnterpriseManagement.Configuration.ManagementPackAccessibility]::Public $groupName="testgroupcreate" $classOfGroup=Get-SCOMClass -DisplayName $groupName -ComputerName $ManagementServer $newmonitor=New-Object microsoft.EnterpriseManagement.Configuration.ManagementPackdependencymonitor($mp,($namespace+[Guid]::NewGuid().Tostring().Replace("-","")),$MPApublic) $newmonitor.DisplayName="test2" $newmonitor.Category=[Microsoft.EnterpriseManagement.Configuration.ManagementPackCategoryType]::Custom $newmonitor.MemberUnAvailable=[Microsoft.EnterpriseManagement.Configuration.HealthState]::Error $newmonitor.membermonitor =[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]]::op_implicit($baseMemberMonitor) $newmonitor.Target = [microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]]::op_implicit($classOfGroup) $newmonitor.relationshiptype =[microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackRelationship]]::op_implicit($baseRelationship) $newmonitor.ParentMonitorID =[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackAggregateMonitor]]::op_implicit($baseParentMonitor) try { $mp.Verify() $mp.AcceptChanges() } catch [Exception] { $_ $mp.RejectChanges() } Ok I have found the way to create ManagementPackElementReference object with powershell . http://www.systemcentercentral.com/Forums/tabid/60/categoryid/4/indexid/57457/Default.aspxyoke88 IMyoke-msn@hotmail.com
Free Windows Admin Tool Kit Click here and download it now
September 13th, 2012 11:38am

$mpName = 'TESTMP' $ManagementServer="sc2012om01" $namespace = $mpName $mp = Get-SCOMManagementPack -name $mpName -ErrorAction Stop -ComputerName $ManagementServer $mg=Get-SCOMManagementGroup -ComputerName $ManagementServer $baseMemberMonitor=Get-SCOMMonitor -ComputerName $ManagementServer -DisplayName '' $baseRelationship=Get-SCOMRelationship -Id fdd1eeb6-e022-761c-58f1-8afd88ffaa88 -ComputerName $ManagementServer $baseParentMonitor=Get-SCOMMonitor -computername $ManagementServer -Id a6c69968-61aa-a6b9-db6e-83a0da6110ea $MPApublic=[Microsoft.EnterpriseManagement.Configuration.ManagementPackAccessibility]::Public $groupName="testgroupcreate" $classOfGroup=Get-SCOMClass -DisplayName $groupName -ComputerName $ManagementServer $newmonitor=New-Object microsoft.EnterpriseManagement.Configuration.ManagementPackdependencymonitor($mp,($namespace+[Guid]::NewGuid().Tostring().Replace("-","")),$MPApublic) $newmonitor.DisplayName="test2" $newmonitor.Category=[Microsoft.EnterpriseManagement.Configuration.ManagementPackCategoryType]::Custom $newmonitor.MemberUnAvailable=[Microsoft.EnterpriseManagement.Configuration.HealthState]::Error $newmonitor.membermonitor =[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackMonitor]]::op_implicit($baseMemberMonitor) $newmonitor.Target = [microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackClass]]::op_implicit($classOfGroup) $newmonitor.relationshiptype =[microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackRelationship]]::op_implicit($baseRelationship) $newmonitor.ParentMonitorID =[Microsoft.EnterpriseManagement.Configuration.ManagementPackElementReference``1[Microsoft.EnterpriseManagement.Configuration.ManagementPackAggregateMonitor]]::op_implicit($baseParentMonitor) try { $mp.Verify() $mp.AcceptChanges() } catch [Exception] { $_ $mp.RejectChanges() } Ok I have found the way to create ManagementPackElementReference object with powershell . http://www.systemcentercentral.com/Forums/tabid/60/categoryid/4/indexid/57457/Default.aspxyoke88 IMyoke-msn@hotmail.com
September 13th, 2012 11:38am

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

Other recent topics Other recent topics