## PowerCLI Reference

# New-AlarmAction

## Synopsis

This cmdlet creates an alarm action and attaches it to the specified alarm.

Syntax

New-AlarmAction [-AlarmDefinition] <AlarmDefinition> -Email [-Subject <String>] -To <String[]> [-Cc <String[]>] [-Body <String>] [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-AlarmAction [-AlarmDefinition] <AlarmDefinition> -Script -ScriptPath <String> [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]
New-AlarmAction [-AlarmDefinition] <AlarmDefinition> -Snmp [-Server <VIServer[]>] [-WhatIf] [-Confirm] [<CommonParameters>]

Related Commands

Online version
Get-AlarmAction
Get-AlarmActionTrigger
Get-AlarmDefinition
New-AlarmActionTrigger
Remove-AlarmAction
Remove-AlarmActionTrigger
Set-AlarmDefinition

Detailed Description

This cmdlet creates an alarm action and attaches it to the specified alarm.

Parameters

Name | Type | Description | Required? | Pipeline Input | Default Value
--- | --- | --- | --- | --- | ---
AlarmDefinition | AlarmDefinition | Specifies the alarm definition for which you want to configure actions. | true | true (ByValue)
Body | String | Specifies the text of the email message. | false | false
Cc | String[] | Specifies the email addresses you want to add to the CC field of the email message. | false | false
Confirm | SwitchParameter | If the value is $true, indicates that the cmdlet asks for confirmation before running. If the value is $false, the cmdlet runs without asking for user confirmation. | false | false
Email | SwitchParameter | Indicates that when the alarm is activated, the system sends an email message to the specified address. Use the Subject, To, CC, and Body parameters to customize the alarm message. | true | false
Script | SwitchParameter | Indicates that a script is run when the alarm is activated. | true | false
ScriptPath | String | Specifies the path to a batch file, located on a vCenter Server system, that will run when the alarm is activated. | true | false
Server | VIServer[] | Specifies the vCenter Server systems on which you want to run the cmdlet. If no value is passed to this parameter, the command runs on the default servers. For more information about default servers, see the description of Connect-VIServer. | false | false
Snmp | SwitchParameter | Indicates that a SNMP message is sent when the alarm is activated. | true | false
Subject | String | Specifies a subject for the email message you want to send. | false | false
To | String[] | Specifies the email address to which you want to send a message. | true | false
WhatIf | SwitchParameter | Indicates that the cmdlet is run only to display the changes that would be made and actually no objects are modified. | false | false

Return Type

The newly created AlarmAction object

Notes

Examples

-------------- Example 1 --------------

    Get-AlarmDefinition -Name "Alarm1" | New-AlarmAction -Snmp

Creates an alarm action SNMP.

-------------- Example 2 --------------

    Get-AlarmDefinition -Name "Alarm1" | New-AlarmAction -Script -ScriptPath 'c:\test.bat'

Creates an alarm action script.

-------------- Example 3 --------------

    Get-AlarmDefinition -Name "Alarm1" | New-AlarmAction -Email -To 'test@vmware.com' -CC @('test1@vmware.com', 'test2@vmware.com') -Body 'Test body' -Subject 'Test subject'

Creates an alarm action Email.

Copyright © VMware, Inc. All rights reserved.