В сценарии PowerShell я пытаюсь выбрать второе MemberShipRule (для UnixComponentGroup) из этого XML-файла:
<Discoveries>
<Discovery ID="Service_ARCHIBUS_SCPopulation" Enabled="true" Target="Service_ARCHIBUS" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes />
<DataSource ID="DS" TypeID="SystemCenter!Microsoft.SystemCenter.GroupPopulator">
<RuleId>$MPElement$</RuleId>
<GroupInstanceId>$Target/Id$</GroupInstanceId>
<MembershipRules>
<MembershipRule>
<MonitoringClass>$MPElement[Name="WindowsComponentGroup_Service_ARCHIBUS"]$</MonitoringClass>
<RelationshipClass>$MPElement[Name="ATS.Application.ARCHIBUS.WindowsServiceHealthRollup"]$</RelationshipClass>
</MembershipRule>
<MembershipRule>
<MonitoringClass>$MPElement[Name="UnixComponentGroup_Service_ARCHIBUS"]$</MonitoringClass>
<RelationshipClass>$MPElement[Name="ATS.Application.ARCHIBUS.UnixServiceHealthRollup"]$</RelationshipClass>
</MembershipRule>
</MembershipRules>
</DataSource>
</Discovery>
</Discoveries>
Строка "ARCHIBUS" хранится в переменной $appnorm. Я пробовал разные версии, моя последняя была:
$xml = Get-Content $apppath
$appnorm = "ARCHIBUS"
$node = $xml.SelectSingleNode('//MembershipRule/MonitoringClass[.=$MPElement[Name="UnixComponentGroup_Service_' + $appnorm + '"]$]')
Результатом всегда является значение null
. Было бы здорово, если бы кто-нибудь мог мне помочь.
Благодарю вас!
С уважением
Ульф