Configuring Microsoft Hyper-V Run Book Actions

Download this manual as a PDF file

This section describes how to customize the run book actions embedded in the "Microsoft Hyper-V AutomationsPowerPack to create run book actions to meet your organization's specific requirements.

For more information about creating automation policies using custom action types, see Configuring Microsoft Hyper-V Automations.

Creating a Custom Action Policy

You can use the "Execute PowerShell Request" action type included with the "Windows PowerShell Automations" PowerPack to create custom run book actions that you can then use to build custom automation policies.

To create a custom action policy using the "Execute PowerShell Request (2.0)" action type:

  • Navigate to the Action Policy Manager page (Registry > Run Book > Actions).
  • In the Action Policy Manager page, click the Create button. The Action Policy Editor modal appears.
  • In the Action Policy Editor page, supply a value in each field.

  • Action Name. Specify the name for the action policy.
  • Action State. Specifies whether the policy can be executed by an automation policy (enabled) or cannot be executed (disabled).
  • Description. Allows you to enter a detailed description of the action.
  • Organization. Organization to associate with the action policy.
  • Action Type. Type of action that will be executed. Select the "Execute PowerShell Request (2.0)" action type.
  • Execution Environment. Select from the list of available Execution Environments. The default execution environment is System.
  • Action Run Context. Select Database or Collector as the context in which the action policy will run.
  • Input Parameters. A JSON structure that specifies each input parameter. Each parameter definition includes its name, data type, and whether the input is optional or required for this Custom Action Type. For more information about the available input parameters, see the table in Creating a Windows PowerShell Run Book Action. Input parameters must be defined as a JSON structure.
  • Click [Save]. If you are modifying an existing action policy, click Save As. Supply a new value in the Action Name field, and save the current action policy, including any edits, as a new policy.

Customizing Run Book Actions

The "Microsoft Hyper-V AutomationsPowerPack includes run book actions that execute the "Execute PowerShell Request" action type to request diagnostic information or remediate an issue. You can specify the commands and the options in the Input Parameters field in the Action Policy Editor modal.

The following run book actions that use the "Execute PowerShell Request" action type are included in the "Microsoft Hyper-V Automations" PowerPack. For more information about input parameter fields, see the table in Creating a New Microsoft Hyper-V Run Book Action.

Action Name Description

Hyper-V Allocation Diagnostic Command

Determines the current resource allocation health of the Hyper-V server or cluster.

Hyper-V Guest Replication Diagnostic Command

Runs a diagnostic command related to Hyper-V guest replication

Hyper-V Guest Status Diagnostic Commands

Runs diagnostic commands to collect Hyper-V guest status and configuration information.

Hyper-V Guest Storage Diagnostic Commands

Runs diagnostic commands related to Hyper-V Guest storage and replication.

Hyper-V Log Collection

Collects the most recent 25 log entries from the Hyper-V logs.

For more information about substitution variables, see the section on Run Book Variables.

Creating a Windows  Hyper-V Run Book Action

You can create a new run book action that runs remote PowerShell requests using the "Execute PowerShell Request" custom action type. To do this, select "Execute PowerShell Request" in the Action Type drop-down list when you create a new run book action. You can also use the existing run book actions in the PowerPack as a template by using the [Save As] option.

The Windows PowerShell run book actions accept the following parameters in JSON:

Parameter Input type Description

commands

string

Specifies a single command or a list of commands, in JSON format, to execute. You can use substitution variables in the commands.

request_key

string

(Optional field)

Default value: empty

The unique key for each instance (row) returned by the request. This unique key must be a property name, and the request must include that property (column) and return values from that property name (column).

Example: Suppose you want to get the ID, number of cores, name, and maximum clock speed of every CPU installed on a Windows system, run the following command, where "DeviceID" is the request key.

Get-WmiObject -Class Win32_Processor -Property DeviceID, NumberOfCores, Name, MaxClockSpeed | Format-List DeviceID, NumberOfCores, Name, MaxClockSpeed

credential_id

integer

Default value: 0

Specifies the credential_id to use for the connection.

  • If set to 0 (false), the custom action type will dynamically determine the credential.
  • If set to an ID number, it maps to the credential ID specified. You can find credential IDs by going to System > Manage > Credentials.

Using Substitution Values. The commands input can contain substitution values that match the keys in EM7_VALUES.

For more information about substitution variables, see the section on Run Book Variables.

For a description of all options that are available in Automation Policies, see the Run Book Automation section.