const HKEY_LOCAL_MACHINE = &H80000002
Dim m_strProduct
Sub Main()
Dim oDiscData
Dim oCollection
Dim oInstance
Dim WshShell
Dim strTempProductPath
Set oDiscData = ScriptContext.CreateDiscoveryData
Set oCollection = oDiscData.CreateCollection
'WriteLog "Microsoft Forefront Service Discovery started."
ScriptContext.Echo "[Trace]: Microsoft Forefront Service Discovery started."
With oCollection
.AddScopeFilter "ComputerName", ScriptContext.TargetComputerIdentity
.ClassID = "ForefrontServer"
.AddScopeComponent "services"
End With
Set oInstance = oCollection.CreateInstance
If ForefrontInstalled Then
With oInstance
.AddKeyProperty "Server Name", ScriptContext.TargetNetbiosComputer
.AddComponent "services"
End With
Else
ScriptContext.Echo "[Trace]: No Microsoft Forefront products found."
End If
ScriptContext.Echo "[Trace]: Forefront Service Discovery script complete."
Set oDiscData = Nothing
Set oCollection = Nothing
Set oInstance = Nothing
End Sub
Function ForefrontInstalled()
Dim arrProducts(1)
arrProducts(0) = "Exchange Server"
arrProducts(1) = "SharePoint" ' Add Forefront for SharePoint support
bFound = false
arrSubKeys = EnumRegKeys("SOFTWARE\Microsoft\Forefront Server Security")
arrSubKeys64 = EnumRegKeys("SOFTWARE\Wow6432Node\Microsoft\Forefront Server Security")
If IsArray(arrSubKeys) Then
For Each product in arrProducts
For Each subkey In arrSubKeys
If subkey = product Then
bFound = true
m_strProduct = product
ScriptContext.Echo "[Trace]: " & product & " found."
End If
Next
Next
Else
ScriptContext.Echo "[Error]: Unable to enumerate HKLM\Software\Microsoft\Forefront Server Security."
End If
If IsArray(arrSubKeys64) Then
For Each product in arrProducts
For Each subkey In arrSubKeys64
If subkey = product Then
bFound = true
m_strProduct = product
ScriptContext.Echo "[Trace]: " & product & " found."
End If
Next
Next
Else
ScriptContext.Echo "[Error]: Unable to enumerate HKLM\Software\Wow6432Node\Microsoft\Forefront Server Security."
End If
ForefrontInstalled = bFound
End Function
Function EnumRegKeys(ByVal strKeyPath)
Dim arrKeys()
Set objReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\default:StdRegProv")
lResult = objReg.EnumKey(HKEY_LOCAL_MACHINE, strKeyPath, arrKeys)
Set objReg = Nothing
EnumRegKeys = arrKeys
End Function </Script></Body>
<Language>VBScript</Language>
<Name>Forefront Service Discovery</Name>
<Parameters/>
<ManagementPackId>[FSMPack2007_FSE,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>