DW data early aggregation write action

Microsoft.Windows.Server.Storage.Visualization.Library.AggregateDashboardData.WriteAction (WriteActionModuleType)

Write action for DW data early aggregation rule

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsMicrosoft.Windows.Server.Storage.Visualization.Library.RunAs.SDK.Rule
InputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
WA WriteAction System.CommandExecuter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$Timeout (seconds)Specifies the time the workflow is allowed to run before being closed and marked as failed.
DebugModebool$Config/DebugMode$

Source Code:

<WriteActionModuleType ID="Microsoft.Windows.Server.Storage.Visualization.Library.AggregateDashboardData.WriteAction" Accessibility="Internal" RunAs="Microsoft.Windows.Server.Storage.Visualization.Library.RunAs.SDK.Rule">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="0" name="DebugMode" type="xsd:boolean"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
<OverrideableParameter ID="DebugMode" ParameterType="bool" Selector="$Config/DebugMode$"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="WA" TypeID="System!System.CommandExecuter">
<ApplicationName>%windir%\System32\WindowsPowerShell\v1.0\powershell.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>
-NoLogo -NoProfile -Noninteractive "$ep = get-executionpolicy; if ( $ep -gt 'RemoteSigned') {set-executionpolicy -Scope Process remotesigned} &amp; '$$file/AggregateDashboardData.ps1$$' -Timeout $Config/TimeoutSeconds$ -DebugMode $Config/DebugMode$"
</CommandLine>
<SecureInput/>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<RequireOutput>false</RequireOutput>
<Files>
<File>
<Name>AggregateDashboardData.ps1</Name>
<Contents><Script>#
# script : AggregateDashboardData.ps1
#
# parameters:
# $Timeout: timeout of executing each stored procedure
# $DebugMode : Debug Mode for capturing the informational events from script
#
param( $Timeout = 10800,$DebugMode)

#TODO: Discuss event id
$SCRIPT_EVENT_ID = 4270
$MODULE = "AggregateDashboardData.ps1"

#Event Severity values
$INFORMATION_EVENT_TYPE = 0
$ERROR_EVENT_TYPE = 2

$api = New-Object -comObject "MOM.ScriptAPI"

function LogError($error_msg )
{
$api.LogScriptEvent($MODULE, $SCRIPT_EVENT_ID, $ERROR_EVENT_TYPE, $error_msg)
}

function LogInformation($msg)
{
$api.LogScriptEvent($MODULE, $SCRIPT_EVENT_ID, $INFORMATION_EVENT_TYPE, $msg)
}

function Main ($SpTimeout) {
# Works, but deprecated method
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager.Common") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.EnterpriseManagement.OperationsManager") | Out-Null
# Doesn't work, but it is how it should be done
#Add-Type -AssemblyName Microsoft.EnterpriseManagement.OperationsManager.Common
#Add-Type -AssemblyName Microsoft.EnterpriseManagement.OperationsManager
#AE: Actually it should be done just using Import-Module OperationsManager. And it works fine.

$ManagementGroup = New-Object Microsoft.EnterpriseManagement.ManagementGroup("localhost")
if (!$ManagementGroup.IsConnected) {
$ManagementGroup.Reconnect();
}

$SpParams = New-Object Microsoft.EnterpriseManagement.Warehouse.StoredProcedureParameterCollection

$ManagementGroup.Reporting.GetDataWarehouse().GetDataWarehouseData("sdk.Microsoft_Windows_Server_Storage_Visualization_Library_UpdateLastValues", $SpParams, $SpTimeout) | Out-Null
if (!$ManagementGroup.IsConnected) {
$ManagementGroup.Reconnect();
}
$ManagementGroup.Reporting.GetDataWarehouse().GetDataWarehouseData("sdk.Microsoft_Windows_Server_Storage_Visualization_Library_UpdateHierarchy", $SpParams, $SpTimeout) | Out-Null
}
try {
if($DebugMode -eq $true)
{
LogInformation 'Starting DW aggregating'
}
Main $Timeout
if($DebugMode -eq $true)
{
LogInformation 'Finished DW aggregating'
}
} catch {
$msg = "($($_.InvocationInfo.ScriptLineNumber)): $($_.InvocationInfo.Line)`r`n Exception: $($_.Exception)"
LogError $msg
}</Script></Contents>
<Unicode>true</Unicode>
</File>
</Files>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="WA"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>