You can designate scripts or workflows to run at specific points during the multi-machine service life cycle. Scripts are run on the Distributed Execution Manager worker machine, not on the guest operating system of the component machine.

For information about how to specify custom logic to run at each stage, see Specify Scripting Information for a Multi-Machine Blueprint.

PowerShell scripts can use the following parameters:

  • VirtualMachine

  • VirtualMachineProperties

  • DataContext

The following PowerShell script is provided as a sample:

# Script to Test InvokePowerShell functions
      $VirtualMachine.Notes = "Test";
       
      foreach ($i in $VirtualMachineProperties)
      {
      $i.PropertyValue = $i.PropertyName;
      }

A PowerShell script can modify some VirtualMachine fields and property values. Not all VirtualMachine parameter fields can be modified.

For related information, see Import Custom PowerShell Scripts in IaaS Configuration for Physical Machines.

Table 1. Script Execution Stages in the Multi-Machine Life Cycle

Stage

Description

Pre-provisioning

Runs after all necessary approvals are complete, but before provisioning any machines.

Post-provisioning

Runs after all component machines are provisioned and powered on.

Pre-startup

Runs before powering on the multi-machine service and all its component machines.

Post-startup

Runs immediately after powering on the multi-machine service and all its component machines. The multi-machine service state is set to On after the post-startup scripts run.

Pre-shutdown

Runs immediately before powering off the multi-machine service and its component machines.

Post-shutdown

Runs after powering off the multi-machine service and its component machines. The multi-machine service state is set to Off after the post-shutdown scripts execute.

Provisioning scripts are run only during the initial provisioning of a multi-machine service. The startup and shutdown scripts are run every time the multi-machine service is powered on or off, except for when the service is initially powered on during provisioning. The pre-provisioning and post-provisioning scripts must include everything that you want to run before and after the initial power on action.

You can also run workflows during the various stages of the multi-machine life cycle. The workflows must accept an argument named MasterMachine of type VirtualMachine (DynamicOps.ManagementModel.VirtualMachine). The Components property of MasterMachine is a list of AppServiceComponents, each of which represents a component machine of the multi-machine service.

Scripts or workflows must be installed in the Model Manager before you can use them in a multi-machine blueprint.