if(bDebug) Log(iSuccessEvent, Log_Info, "Beginning script in DEBUG mode.");
/*
Get's a registry key's value.
NOTE: Always looks in HKLM (Local Machine).
sKey - The registry key's name
sValueName - the value's name
iValueType - the value's type - this is either a string (1) or a DWRORD (2)
*/
var oWShell = new ActiveXObject("WScript.Shell");
function RetrieveRegValue (sKey, sValueName, iValueType)
{
var sRegValue = null;
try
{
sRegValue = oWShell.RegRead("HKLM\\"+sKey+"\\"+sValueName);
}
catch (e)
{
if(bDebug) Log(iErrorEvent, Log_Warning, "Error getting key. Key: "+sKey+"\\"+sValueName);
}
return sRegValue;
}
/*
Reads the Forefront Install Path from the registry and returns it.
Returns null if it could not read the value.
*/
function GetInstallPath(sProductRegKey)
{
var sFSOCSInstallPath;
var sFFKey = "SOFTWARE\\Microsoft\\Forefront Server Security\\";
var sFFWOWKey = "SOFTWARE\\Wow6432Node\\Microsoft\\Forefront Server Security\\";
// File System helper object
var FSO = new Object();
FSO.obj = new ActiveXObject("Scripting.FileSystemObject");
FSO.FileExists = function (sPath)
{
return FSO.obj.FileExists(sPath);
}
FSO.GetVersion = function(sPath)
{
return FSO.obj.GetFileVersion(sPath);
}
// End FSO
/*
Returns whether the installed version of forefront is a "Version 10" product
*/
function IsFF10(sInstallPath)
{
// Get the version of FSCController to see if we're Version 10
var sVersion = FSO.GetVersion(sInstallPath + "\\FSCController.exe");
if(!sVersion) return false;
return sVersion.split(".")[0] == "10";
}
/*
Execute a method (most likely an inline anonymous function), and log success or error.
Only logs success when in DEBUG mode, but always on error. When an error occurs, the
script is terminated abruptly
*/
function Ex(f, sMsg)
{
try
{
f();
}
catch(e)
{
Log(iErrorEvent, Log_Error, "Error: " + (sMsg || "Unknown error"));
WScript.Quit(1);
}
// attempt to determine whether the forefront registry key exists ...
var sInstallPath = GetInstallPath("Office Communications Server");
if(bDebug) Log(iSuccessEvent, Log_Info, "Install Path: "+sInstallPath);
var oDiscoveryData = oAPI.CreateDiscoveryData(0, sSourceId, sManagedEntityId);
if(sInstallPath)
{
// if it does, figure out if it's Version 10
var bIs10 = IsFF10(sInstallPath);
if(bDebug) Log(iSuccessEvent, Log_Info, "Is Version 10: "+bIs10);
if(bIs10)
{
if(bDebug) Log(iSuccessEvent, Log_Info, "Detected Forefront Server for Office Communications Server (Version 10)");
CreateSCOMObject(oDiscoveryData,
"$MPElement[Name='Microsoft.ForefrontServer10.FSOCS.Server']$",
"Microsoft Forefront Security for Office Communications Server (Version 10)",
"ForefrontServer10.FSOCS.Server");