var EXPECTED_ARGUMENT_COUNT = 9;
var UNEXPECTED_ARGUMENT_COUNT_ERROR_ID = 101;
var DISCOVERY_STARTED_INF_ID = 1470;
var DISCOVERY_ENDED_INF_ID = 1471;
var DISCOVERY_PROGRESS_INF_ID = 1472;
var EVENT_SOURCE = "MicrosoftExchangeMailboxComponentDiscovery.js";
var EVENT_TYPE_ERROR = 1;
var EVENT_TYPE_WARNING = 2;
var EVENT_TYPE_INFORMATION = 4;
var oAPI = new ActiveXObject("Mom.ScriptAPI");
var argumentsStr = "";
for (var i = 0; i < WScript.Arguments.length; i++)
{
argumentsStr = argumentsStr.concat("\"", WScript.Arguments(i), "\" ");
}
if (WScript.Arguments.length != EXPECTED_ARGUMENT_COUNT)
{
oAPI.LogScriptEvent(
EVENT_SOURCE,
UNEXPECTED_ARGUMENT_COUNT_ERROR_ID,
EVENT_TYPE_ERROR,
"Expected " + EXPECTED_ARGUMENT_COUNT + " arguments. But there were " + WScript.Arguments.length + " arguments. Exiting script.\n Arguments: " + argumentsStr);
WScript.Quit(-1);
}
var sourceType = WScript.Arguments(0);
var sourceId = WScript.Arguments(1);
var managedEntityId = WScript.Arguments(2);
var computerPrincipalName = WScript.Arguments(3);
var computerNetbiosName = WScript.Arguments(4);
var computerActiveDirectorySite = WScript.Arguments(5);
var isVirtualServerString = WScript.Arguments(6); // For MailboxRole, this should always have value of either "true" or "false"
var isDatacenterString = WScript.Arguments(7); // Should have value of either "true" or "false".
var verboseLoggingString = WScript.Arguments(8);
// Convert variables from string to bool.
var isVirtualServer = (isVirtualServerString.toLowerCase() == "true") ? true : false;
var isDatacenter = (isDatacenterString.toLowerCase() == "true") ? true : false;
var verboseLogging = (verboseLoggingString.toLowerCase() == "true") ? true : false;
// Create the MailboxTransportThrottlingServer instance.
var oMbxTransportThrottlingServer = discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Exchange.2010.MailboxTransportThrottlingServer']$");
oMbxTransportThrottlingServer.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", computerPrincipalName);
oMbxTransportThrottlingServer.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.ServerRole']/RoleName$", mailboxRoleName);
oMbxTransportThrottlingServer.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Component']/ComponentName$", "Transport Throttling Server - " + mailboxRoleName);
discoveryData.AddInstance(oMbxTransportThrottlingServer);
// ----------------------------------------------------------------------
// Instantiate org level service classes related to MailboxComponent.
// ----------------------------------------------------------------------
//
// Create the MapiService instance.
var oMapiService = discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Exchange.2010.MailboxMapiService']$");
oMapiService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/ServiceName$", "MAPI Service - " + computerActiveDirectorySite);
oMapiService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/InstanceName$", computerActiveDirectorySite);
oMapiService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/ActiveDirectorySite$", computerActiveDirectorySite);
discoveryData.AddInstance(oMapiService);
// ----------------------------------------------------------------------
// Instantiate org level service classes related to CommonComponent.
// ----------------------------------------------------------------------
//
// Create the CommonRemotePowerShellService instance.
var oCommonRemotePowerShellService = discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Exchange.2010.CommonRemotePowerShellService']$");
oCommonRemotePowerShellService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/ServiceName$", "Remote PowerShell Service - " + computerActiveDirectorySite);
oCommonRemotePowerShellService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/InstanceName$", computerActiveDirectorySite);
oCommonRemotePowerShellService.AddProperty("$MPElement[Name='Microsoft.Exchange.2010.Service']/ActiveDirectorySite$", computerActiveDirectorySite);
discoveryData.AddInstance(oCommonRemotePowerShellService);
// ----------------------------------------------------------------------
// Create relationships from org level services to MailboxComponent.
// ----------------------------------------------------------------------
//
// Create containment relationship from MapiService to Mailbox.MailboxMonitoring.
var oMapiServiceServiceContainsMbxMailboxMonitoring = discoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Exchange.2010.MailboxMapiService.Contains.Microsoft.Exchange.2010.Mailbox.MailboxMonitoring']$");
oMapiServiceServiceContainsMbxMailboxMonitoring.Source = oMapiService;
oMapiServiceServiceContainsMbxMailboxMonitoring.Target = oMbxMailboxMonitoring;
discoveryData.AddInstance(oMapiServiceServiceContainsMbxMailboxMonitoring);
// ----------------------------------------------------------------------
// Create relationships from org level services to CommonComponent.
// ----------------------------------------------------------------------
//
if (false == isDatacenter)
{
// Create containment relationship from CommonRemotePowerShellService to CommonRemotePowerShell only when Datacenter management pack is not installed.
var oCommonRemotePowerShellServiceContainsCommonRemotePowerShell = discoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Exchange.2010.CommonRemotePowerShellService.Contains.Microsoft.Exchange.2010.CommonRemotePowerShell']$");
oCommonRemotePowerShellServiceContainsCommonRemotePowerShell.Source = oCommonRemotePowerShellService;
oCommonRemotePowerShellServiceContainsCommonRemotePowerShell.Target = oCommonRemotePowerShell;
discoveryData.AddInstance(oCommonRemotePowerShellServiceContainsCommonRemotePowerShell);
}