if oArgs.Count < 5 Then
call oAPI.LogScriptEvent("ClientAutoDeployment::DPMServerDiscovery", 12, 1, "Expected 5 arguments. There were only "_
& oArgs.Count & " arguments. Exiting script.")
Wscript.Quit -1
End If
Set oDiscData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
dpmProductCodes = Array("{2A78E931-1931-46BA-9EB1-6E052D8927CA}", "{AEFAD2C8-054F-4EBF-8560-C09E883D9999}")
Set oInst = oDiscData.CreateClassInstance("$MPElement[Name="Microsoft.Windows.SystemCenterDPM2010.ClientAutoDeployment.DPMServer"]$")
For Each dpmCode In dpmProductCodes
installstate = MsiQueryProductState(dpmCode)
If installstate = msiInstallStateUnknown or installState = msiInstallStateAbsent then
'MsgBox("Dpm not found")
Else
dpmversion = MsiGetProductInfo(dpmCode)
'MsgBox("DPM is Present:" & dpmversion)
call oDiscData.AddInstance(oInst)
Exit For
End if
Next
call oAPI.Return(oDiscData)
Function MsiQueryProductState(ProductCode)
Dim InstallState
Dim Installer : Set Installer = Nothing
Set Installer = CreateObject("WindowsInstaller.Installer")
InstallState = Installer.ProductState(ProductCode)
MsiQueryProductState = InstallState
Exit Function
End Function
Function MsiGetProductInfo(ProductCode)
Dim InstallInfo
Dim Installer : Set Installer = Nothing
Set Installer = CreateObject("WindowsInstaller.Installer")
InstallInfo = Installer.ProductInfo(ProductCode,"VersionString")
MsiGetProductInfo = InstallInfo
End Function</Script></ScriptBody>
<TimeoutSeconds>600</TimeoutSeconds>
</DataSource>
</Discovery>