Publish Exchange MP Data WA

Publish_ExMP_Data.WriteAction (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsSystem.PrivilegedMonitoringAccount
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
Script WriteAction Microsoft.Windows.ScriptWriteAction Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds

Source Code:

<WriteActionModuleType ID="Publish_ExMP_Data.WriteAction" Accessibility="Internal" RunAs="System!System.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<xsd:element name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
<ScriptName>Publish_ExMP_Data.js</ScriptName>
<Arguments/>
<ScriptBody><Script>
// Event Constants
var EVENT_SOURCE = "Exchange MOM";
var EVENT_TYPE_SUCCESS = 0;
var EVENT_TYPE_ERROR = 1;
var EVENT_TYPE_WARNING = 2;
var EVENT_TYPE_INFORMATION = 4;

var oAPI = new ActiveXObject("Mom.ScriptAPI");

function CreateEvent(lngEventID, lngEventType, strMsg)
{
oAPI.LogScriptEvent(EVENT_SOURCE, lngEventID, lngEventType, strMsg);
}

function EchoEvent(lngEventID, lngEventType, strMsg)
{
var sevString;

switch(lngEventType)
{
case EVENT_TYPE_SUCCESS: sevString = "Success"; break;
case EVENT_TYPE_ERROR: sevString = "Error"; break;
case EVENT_TYPE_WARNING: sevString = "Warning"; break;
case EVENT_TYPE_INFORMATION: sevString = "Infomation"; break;
}

if (lngEventType != EVENT_TYPE_SUCCESS)
{
WScript.Echo(EVENT_SOURCE , "Event ID:" , lngEventID , "Severity: " , sevString);
WScript.Echo(strMsg);
}
}

function HResultToString(hresult)
{
return "0x" + (hresult &lt; 0 ? hresult + 0x100000000 : hresult).toString(16).toUpperCase() + "(" + hresult +")";
}


//Copyright (c) Microsoft Corporation. All rights reserved.
//*************************************************************
// $ScriptName: "Publish ExMP Data" $
//
// Events created by this script:
// SOURCE ID TYPE DESCRIPTION
// Exchange MOM 10000 error Failed to publish Exchange Management Pack data
// Exchange MOM 10001 error Failed to create the PubKeyPublisher object
// Exchange MOM 9986 info Successfully published Exchange Management Pack data
//
// $File: Publish_ExMP_Data.js $
//*************************************************************

// Event Constants
EVENT_SOURCE = "Publish ExMP Data";
// Event ID Constants
var EVENT_ID_BASE_STATE_OK = 10000;

//Other Variables

PublishExMPData:
{
try {
// Other Constants
var SUCCESS = 0;
var WshNetwork = new ActiveXObject("WScript.Network");
var strServerName = WshNetwork.ComputerName;
var PubKeyPublisherObjName;
PubKeyPublisherObjName = "EMPKP.PubKeyPublisher";
try {
var objKP = new ActiveXObject(PubKeyPublisherObjName);
}catch(err){
CreateEvent(10001, EVENT_TYPE_ERROR, "Failed to create the object '" + PubKeyPublisherObjName + "'.");
break PublishExMPData;
}
var errID;
errID = objKP.Publish();
if (errID != SUCCESS)
CreateEvent(10000, EVENT_TYPE_ERROR, "Failed to publish Exchange Management Pack data required for performing MAPI logon on Exchange server:\"" + strServerName + ".\nError information:\n" + HResultToString(errID));
else
CreateEvent(9986, EVENT_TYPE_INFORMATION, "Successfully published Exchange Management Pack data required for performing MAPI logon on Exchange server:\"" + strServerName);
}catch(err){
CreateEvent(10000, EVENT_TYPE_ERROR, "Failed to publish Exchange Management Pack data required for performing MAPI logon on Exchange server:\"" + strServerName + ".\nError information:\n" + HResultToString(err.number) + " " + err.description);
}
}


</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="Script"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>