Acer.Server.OOB.PRO.Recovery

Acer.Server.OOB.PRO.Recovery (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsMicrosoft.SystemCenter.PrivilegedMonitoringAccount
InputTypeSystem.BaseData
OutputTypeSystem.CommandOutput

Member Modules:

ID Module Type TypeId RunAs 
Recovery WriteAction System.CommandExecuter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
EventDescriptionstring$Config/EventDescription$EventDescription

Source Code:

<WriteActionModuleType ID="Acer.Server.OOB.PRO.Recovery" Accessibility="Internal" RunAs="SC!Microsoft.SystemCenter.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="EventDescription" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="EventDescription" Selector="$Config/EventDescription$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="Recovery" TypeID="System!System.CommandExecuter">
<ApplicationName>%SystemRoot%\system32\windowspowershell\v1.0\powershell.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>"&amp; '$file/RecoveryScript.ps1$' '$Config/EventDescription$'"</CommandLine>
<TimeoutSeconds>86400</TimeoutSeconds>
<RequireOutput>false</RequireOutput>
<Files>
<File>
<Name>RecoveryScript.ps1</Name>
<Contents><Script>
#############################################################################
# Filename: RecoveryScript.ps1
# Description: The script places the host into maintenance mode.
#############################################################################

eventcreate /T Information /ID 100 /L APPLICATION /SO AcerPRO /D 'Start to execuite RecoveryScript.ps1';

$eventContent = $args[0];

#Parse the contents and put the parameters into an array
$eventContent = $eventContent.Split(':');

#Check to ensure all of the expected parameters have been passed
if($eventContent.Count -Lt 4) { eventcreate /T Error /ID 100 /L APPLICATION /SO AcerPRO /D 'Invalid number of parameters are passed to the RecoveryScript.ps1.'; return; }

#Put respective parameters into expected variables
$hostName = $eventContent[$eventContent.Count - 4].Replace('\n','').Trim();
$serverName = $eventContent[$eventContent.Count - 3].Trim();
$ProtipId = $eventContent[$eventContent.Count - 2].Trim();
$vmErrorCode = $eventContent[$eventContent.Count - 1].Trim()[0];

$Error.Clear();

#eventcreate /T Information /ID 100 /L APPLICATION /SO AcerPRO /D 'add snapin';

#Add the VMM PowerShell Snapin so you can use the cmdlets
add-pssnapin -name Microsoft.SystemCenter.VirtualMachineManager;

#eventcreate /T Information /ID 100 /L APPLICATION /SO AcerPRO /D 'establish connection';
#Establish connection to the VMM server
$VMMServer = get-vmmserver -computerName $serverName;
$VMHost = Get-VMHost -ComputerName $hostName;
Write-Host "Placing host" $VMHost "into maintenance mode.";

eventcreate /T Information /ID 100 /L APPLICATION /SO AcerPRO /D 'Start to execute Disable-VMHost cmdlet';
Disable-VMHost $VMHost -PROTipID $ProtipId;

#eventcreate /T Information /ID 100 /L APPLICATION /SO AcerPRO /D 'set pro tip status';
#Set the PRO tip status to Resolved once the processing is complete
Set-PROTip -PROTipId $ProtipId -TipStatus Resolved;
</Script></Contents>
</File>
</Files>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="Recovery"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.CommandOutput</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>