Discovery of Operations Manager deployment
Microsoft.SystemCenter.OM.Products.Discovery (Discovery)
This discovers the Operations Manager deployed versions.
Element properties:
Member Modules:
Source Code:
<Discovery ID="Microsoft.SystemCenter.OM.Products.Discovery" Target="SCLibrary!Microsoft.SystemCenter.HealthService" Enabled="true" ConfirmDelivery="false" Remotable="false" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes/>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>86400</IntervalSeconds>
<SyncTime/>
<ScriptName>SCOMInstalledProducts</ScriptName>
<ScriptBody><Script>
param($IsRHS)
$IsRHS = [boolean]::Parse($IsRHS)
$products = Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | Select-Object DisplayName, DisplayVersion, InstallDate, PSChildName | Where-Object {$_.DisplayName -like '*Operations Manager*' -or $_.DisplayName -eq 'Microsoft Monitoring Agent'}
# Create a new discovery data packet
$oAPI = new-object -comObject "MOM.ScriptAPI"
$oDisc = $oAPI.CreateDiscoveryData(0, "$MPElement$", "$Target/Id$")
$oDisc.IsSnapshot = $True
foreach($OMproduct in $products)
{
if(-not $OMproduct.PSChildName.startswith("{"))
{
continue;
}
$productComponentID = $OMproduct.PSChildName
$installer = new-object -comobject "WindowsInstaller.Installer"
$productList = @($installer.GetType().InvokeMember("ProductsEx", "GetProperty", $null, $installer,('', '', 4)))
$patchListString = ""
$InstallDate = ""
$KBNumber = ""
foreach($product in $productList)
{
$ProductCode=$product.GetType().InvokeMember("ProductCode", "GetProperty", $null, $product, 1)
if($ProductCode -eq $productComponentID)
{
$patchList=$installer.GetType().InvokeMember("PatchesEx", "GetProperty", $null, $installer,($ProductCode, "", 7, 1))
foreach($patch in $patchList)
{
$patchListString = $patch.GetType().InvokeMember("PatchProperty", [System.Reflection.BindingFlags]::GetProperty, $Null, $patch, "DisplayName")
$InstallDate = $patch.GetType().InvokeMember("PatchProperty", [System.Reflection.BindingFlags]::GetProperty, $Null, $patch, "InstallDate")
$PackageName = $patch.GetType().InvokeMember("SourceListInfo", [System.Reflection.BindingFlags]::GetProperty, $Null, $patch, "PackageName")
$PackageName = $PackageName.Split("-")
$KBNumber = $PackageName[0]
}
}
}
if($patchListString -ne $null -and $patchListString -ne "")
{
$patchListString = $patchListString.Substring($patchListString.IndexOf("Manager") + 8)
}
if($InstallDate -ne $null -and $InstallDate -ne "")
{
$InstallDate = [datetime]::ParseExact($InstallDate,”yyyyMMdd”,$null).toshortdatestring()
}else{
$InstallDate = [datetime]::ParseExact($OMproduct.InstallDate,”yyyyMMdd”,$null).toshortdatestring()
}
switch -wildcard ($OMproduct.DisplayName)
{
"*Agent" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Agent']$"); break }
"*Reporting*" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Reporting']$"); break }
"*Audit Collection Server*" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.ACS']$"); break }
"*Server" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.OM']$"); break }
"*Web Console" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.WebConsole']$"); break }
"*Console" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Console']$"); break }
"*Gateway" { $oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Gateway']$") }
}
$oInst1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$")
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/ProductDisplayName$", $OMproduct.DisplayName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/Domain$", "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/DomainDnsName$")
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/ComputerName$", "$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetworkName$")
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/PatchInstalled$", $patchListString)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/InstallDate$", $InstallDate)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/Version$", $OMproduct.DisplayVersion)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts']/KBNumber$", $KBNumber)
IF( ($OMproduct.DisplayName -like '*Agent') -or ($OMproduct.DisplayName -like '*Manager Server') -or ($OMproduct.DisplayName -like '*Gateway') )
{
$LogOnTypeRegPath = "HKLM:\SOFTWARE\Policies\Microsoft\System Center\Health Service"
$LogOnTypeRegKey = "Worker Process Logon Type"
IF(!(Test-Path $LogOnTypeRegPath))
{
IF(($OMproduct.DisplayVersion.Split('.'))[0] -ge 10)
{
$LogOnType = "Service"
}
ELSE
{
$LogOnType = "Interactive"
}
}
ELSE
{
$LogOnTypeNumber = (Get-ItemProperty -Path $LogOnTypeRegPath -Name $LogOnTypeRegKey).$LogOnTypeRegKey
Switch($LogOnTypeNumber)
{
"2" {$LogOnType = "Interactive"; break;}
"8" {$LogOnType = "NetworkCleartext"; break;}
"5" {$LogOnType = 'Service'; break;}
"4" {$LogOnType = 'Batch'; break;}
default {$LogOnType = 'Invalid';}
}
}
switch -wildcard ($OMproduct.DisplayName)
{
"*Agent" { $oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Agent']/AccountLogOnType$", $LogOnType); break }
"*Manager Server" { $oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.OM']/AccountLogOnType$", $LogOnType); break }
"*Gateway" { $oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.OMProducts.Gateway']/AccountLogOnType$", $LogOnType); break }
}
}
$oDisc.AddInstance($oInst1)
}
if($IsRHS)
{
$SCOMPowerShellKey = "HKLM:\SOFTWARE\Microsoft\System Center Operations Manager\12\Setup\Powershell\V2"
$SCOMModulePath = Join-Path (Get-ItemProperty $SCOMPowerShellKey).InstallDirectory “OperationsManager”
Import-module $SCOMModulePath
$DBInfo = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\" | Select-Object DatabaseServerName, DataWarehouseDBServerName, DatabaseName, DataWarehouseDBName
#Database Discovery
$computerName = [System.Net.Dns]::GetHostEntry($DBInfo.DatabaseServerName.Split('\')[0]).HostName
$dbVersion = Get-SCOMOperationsDatabase
$oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']$");
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/InstanceName$", $DBInfo.DatabaseServerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/ProductDisplayName$", "Operations Manager Database")
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/DatabaseName$", $DBInfo.DatabaseName)
$oInst1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/ComputerName$", $computerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/Version$", $dbVersion)
$oDisc.AddInstance($oInst1)
#Data Warehouse Discovery
$computerName = [System.Net.Dns]::GetHostEntry($DBInfo.DataWarehouseDBServerName.Split('\')[0]).HostName
$params = New-Object Microsoft.EnterpriseManagement.Warehouse.StoredProcedureParameterCollection
$dwVersion = $($($(Get-SCOMManagementGroup).GetDataWarehouse()).GetDataWarehouseData("sdk.p_GetDatawarehouseVersion", $params)).Results[0].Values[0]
$oInst1 = $oDisc.CreateClassInstance("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']$");
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/InstanceName$", $DBInfo.DataWarehouseDBServerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/ProductDisplayName$", "Operations Manager Data Warehouse")
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/DatabaseName$", $DBInfo.DataWarehouseDBName)
$oInst1.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", $computerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/ComputerName$", $computerName)
$oInst1.AddProperty("$MPElement[Name='Microsoft.SystemCenter.Installed.Database']/Version$", $dwVersion)
$oDisc.AddInstance($oInst1)
}
$oDisc
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>IsRHS</Name>
<Value>$Target/Property[Type="SCLibrary!Microsoft.SystemCenter.HealthService"]/IsRHS$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>900</TimeoutSeconds>
</DataSource>
</Discovery>