VMware Virtual Machine object group based on AD

Unleash the power of System Center for vSphere and Hyper-V | Veeam Task Manager for Hyper-V

VMware Virtual Machine object group based on AD

Veeam Logoby sbanyas » Wed May 25, 2016 9:12 pm

Kinda a weird one here that I haven't been able to figure out ... yet.

I'm trying to create a "dynamic" group within SCOM based on server(s) in an Active Directory group. I'm using pieces of Powershell script originally written by Arjan Vroege.

I can get the Windows Computer object to populate in the group correctly, but am struggling with the VMware Virtual Machine object. (we need both objects for the server(s) for dashboarding purposes).

The code snippets are from my custom MP:
<ClassType ID="FBL.Troubleshooting.AD.Group" Accessibility="Public" Abstract="false" Base="System!System.Group" Hosted="false" Singleton="true" Extension="false" />
<RelationshipType ID="FBL.Troubleshooting.AD.Group.Contains.Windows.Computer" Accessibility="Internal" Abstract="false" Base="System!System.Containment">
<Source ID="FBL.Troubleshooting.AD.Group.Rel.Source" Type="FBL.Troubleshooting.AD.Group" />
<Target ID="FBL.Troubleshooting.AD.Group.Rel.Target.Windows.Computer" Type="Windows!Microsoft.Windows.Computer" />
<RelationshipType ID="FBL.Troubleshooting.AD.Group.Contains.VMware.VMGUEST" Accessibility="Internal" Abstract="false" Base="System!System.Containment">
<Source ID="FBL.Troubleshooting.AD.Group.Rel.Source" Type="FBL.Troubleshooting.AD.Group" />
<Target ID="FBL.Troubleshooting.AD.Group.Rel.Target.VMware.VMGUEST" Type="VeeamVirtExtensionsVMwareLibrary8002218!Veeam.Virt.Extensions.VMware.VMGUEST" />
<Discovery ID="FBL.Troubleshooting.AD.Group.DiscoveryRule" Enabled="true" Target="SystemCenter!Microsoft.SystemCenter.RootManagementServer" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<DiscoveryClass TypeID="FBL.Troubleshooting.AD.Group" />
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<SyncTime />
# AD_GroupDiscovery_check.ps1
# Written by Arjan Vroege. All rights reserved.

param($SourceID, $ManagedEntityID)

Clear-Variable -Name groupInstance
Clear-Variable -Name groupmembers
Clear-Variable -Name member
Clear-Variable -Name DNSHostName

$scomapi = new-object -comObject "MOM.ScriptAPI"
$DiscData = $scomapi.CreateDiscoveryData(0, $SourceID, $ManagedEntityID)

$scomapi.LogScriptEvent("AD_GroupDiscovery_check.ps1",101,0, "Discovery was executed")

$groupInstance = $DiscData.CreateClassInstance("$MPElement[Name='FBL.Troubleshooting.AD.Group']$")

$groupmembers = Get-ADGroupMember -Identity "SAVAGETestGroup"
foreach($member in $groupmembers) {
$DNSHostName = Get-ADComputer -Filter 'Name -eq $member.Name' | Select -Expand DNSHostName
If($DNSHostName) {
$scomapi.LogScriptEvent("AD_GroupDiscovery_check.ps1",101,0, "Instance $DNSHostName")

$ComputerServerInstance = $DiscData.CreateClassInstance("$MPElement[Name='Windows!Microsoft.Windows.Server.Computer']$")
$ComputerServerInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $DNSHostName)

$ComputerRelationshipInstance = $DiscData.CreateRelationshipInstance("$MPElement[Name='FBL.Troubleshooting.AD.Group.Contains.Windows.Computer']$")
$ComputerRelationshipInstance.Source = $groupInstance
$ComputerRelationshipInstance.Target = $ComputerServerInstance

<!-- Instantiates the Veeam class -->
$VMGUESTServerInstance = $DiscData.CreateClassInstance("$MPElement[Name='VeeamVirtExtensionsVMwareLibrary8002218!Veeam.Virt.Extensions.VMware.VMGUEST']$")
$VMGUESTServerInstance.AddProperty("$MPElement[Name="VeeamVirtExtensionsVMwareLibrary8002218!Veeam.Virt.Extensions.VMware.VMGUEST"]/guestHostName$", $DNSHostName)

$VMGUESTRelationshipInstance = $DiscData.CreateRelationshipInstance("$MPElement[Name='FBL.Troubleshooting.AD.Group.Contains.VMware.VMGUEST']$")
$VMGUESTRelationshipInstance.Source = $groupInstance
$VMGUESTRelationshipInstance.Target = $VMGUESTServerInstance

} Else {
$scomapi.LogScriptEvent("AD_GroupDiscovery_check.ps1",101,2, "$member instance is not a computer")


The following is an error code in my Operations Manager event log:

Discovery data couldn't be inserted to the database. This could have happened because of one of the following reasons:

- Discovery data is stale. The discovery data is generated by an MP recently deleted.
- Database connectivity problems or database running out of space.
- Discovery data received is not valid.

The following details should help to further diagnose:

DiscoveryId: ec3c0971-1ccf-28c0-7613-0d88d1b65c30
HealthServiceId: eead0f7c-62a4-c185-2ba5-4e0ee925fb60
Microsoft.EnterpriseManagement.Common.DiscoveryDataMissingKeyException,Missing key in the discovery data item.
Key property name: Veeam.Virt.Extensions.VMware.VMGUEST.id
Rule ID: ec3c0971-1ccf-28c0-7613-0d88d1b65c30
<?xml version="1.0" encoding="utf-16"?><ClassInstance TypeId="{c16b369d-03d1-b8dc-dc18-e898f96288d3}"><Settings><Setting><Name>b6f2cb36-e6f4-d554-0c6b-fbfc00cc9b58</Name><Value>phoscsccm03.fbfs.com</Value></Setting></Settings></ClassInstance>.
Posts: 7
Liked: never
Joined: Wed Jul 01, 2015 8:46 pm
Full Name: Scott Banyas

Re: VMware Virtual Machine object group based on AD

Veeam Logoby Alec King » Wed May 25, 2016 10:26 pm

Hi Scott,

At first glance it looks like your discovery/script is not providing the essential Key ID property for VMGuest Virtual Machine - Veeam.Virt.Extensions.VMware.VMGUEST.id.

This is the only key ID property for that class. Unlike Windows server class, the DNS Name is NOT the key ID property for VM class.

The VMGUEST Key ID is made of vCenter Name + VM MOREF (vCenter ID for the VM) and will look something like 'PRODVC.domain.local:VM-1234'.

I'll get my team to double-check your script and post back here.

Alec King
Veeam Software
Posts: 700
Liked: 116 times
Joined: Sun Jan 01, 2006 1:01 am

Re: VMware Virtual Machine object group based on AD

Veeam Logoby sergey.g » Thu May 26, 2016 3:23 pm

Hi Scott,

I'll try to add more, but Alec is correct and you need to find ID of a VM with the corresponding DNS name. I was able to come up with something like this:

Code: Select all
$VM_id=get-scomclass -name "Veeam.Virt*VMware*VMGUEST" | get-scomclassinstance | select name, @{n='DNS';e={$_ | select -expand values | ? {$_.Type -like "guesthostname"}}} | ? {$_.DNS -like $DNSHostName}

Then $VM_id.Name will contain ID of the Virtual Machine which you can use for creating it for the releationship target

Code: Select all
$VMGUESTServerInstance.AddProperty("$MPElement[Name="VeeamVirtExtensionsVMwareLibrary8002218!Veeam.Virt.Extensions.VMware.VMGUEST"]/id$", $VM_id.Name)
Veeam Software
Posts: 453
Liked: 75 times
Joined: Wed May 02, 2012 1:49 pm
Full Name: Sergey Goncharenko

Return to Veeam Management Pack for Microsoft System Center

Who is online

Users browsing this forum: No registered users and 3 guests