---
title: "PowerShell Cmdlets for Trigger Templates"
slug: "powershell-cmdlets-for-trigger-templates"
updated: 2025-05-04T12:28:22Z
published: 2025-05-04T12:28:22Z
canonical: "support.controlup.com/powershell-cmdlets-for-trigger-templates"
---

> ## Documentation Index
> Fetch the complete documentation index at: https://support.controlup.com/llms.txt
> Use this file to discover all available pages before exploring further.

# PowerShell Cmdlets for Trigger Templates

From version 9.0.5 and higher, you can run the following [PowerShell cmdlets](/v1/docs/powershell-cmdlets-for-triggers) to configure trigger [notification templates](/v1/docs/notification-templates) on a machine with a ControlUp Monitor installed:

- [Add-CUTriggerTemplate](/v1/docs/powershell-cmdlets-for-trigger-templates#addcutriggertemplate). Adds a new trigger template.
- [Update-CUTriggerTemplate](/v1/docs/powershell-cmdlets-for-trigger-templates#updatecutriggertemplate). Updates an existing trigger template.
- [Remove-CUTriggerTemplate](/v1/docs/powershell-cmdlets-for-trigger-templates#removecutriggertemplate). Deletes an existing trigger template.
- [Get-CUTriggerTemplates](/v1/docs/powershell-cmdlets-for-trigger-templates#getcutriggertemplates). Lists all available trigger templates, or specific trigger templates.

#### Add-CUTriggerTemplate

Adds a new trigger template to the template repository. Doesn't add a template to a trigger.

**Syntax**

```powershell
Add-CUTriggerTemplate
-Name <string>
-Type <TriggerTemplateType>
-Body <string>
-Subject <string>
-HttpHeaders <string>
-DisableJSONValidation <string>
```

Add general trigger template example:

```powershell
Add-CUTriggerTemplate -Name @QA-General-STRESS -Type General -Body 'Your monitored resource has crossed a configured Stress Level threshold.
	+Organization Name: $(OrgName)

	+Folder name: $(CUFolderName)

	+Reported by: $(ReportedBy)

	+Trigger name: $(TriggerName)

	Resource name: $(ObjectName)

	Resource type: $(ResourceType)

	=> Stress Level: $(StressLevel) <=

	Incident timestamp ($(Timezone)): $(Timestamp)

	Counters involved in this incident:

$(ListOfColumns:"		Counter: $(Column)

		Severity Level: $(ColumnSeverityLevel)

		Since ($(Timezone)): $(ColumnTimestamp)

		Threshold crossed: $(ColumnCrossedThreshold)")' -Subject 'STRESS >> ControlUp alert mail - $(TriggerType) - $(Object)'
```

Add webhook trigger template example:

```powershell
Add-CUTriggerTemplate -Name @QA-Webhook02 -Type Webhook -Body '{
   "templateName":"---@QA-Webhook02",
   "type":"message",
   "attachments":[
	  {
  "contentType": "application/vnd.microsoft.card.adaptive",
  "content": {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "001",
    "body": [
      {
        "type": "Container",
        "items": [
          {
            "type": "FactSet",
            "facts": [
              {
                "title": "Organization Name:",
                "value": "$(OrgName)"
              },
              {
                "title": "Folder name:",
                "value": "$(CUFolderName)"
              },
              {
                "title": "Reported by:",
                "value": "$(ReportedBy)"
              },
              {
                "title": "Trigger name:",
                "value": "$(TriggerName)"
              },
              {
                "title": "Object:",
                "value": "$(Object)"
              },
              {
                "title": "ComputerName:",
                "value": "$(CompName)"
              },
              {
                "title": "Resource name:",
                "value": "$(ObjectName)"
              },
              {
                "title": "Resource type:",
                "value": "$(ResourceType)"
              },
              {
                "title": "Stress Level:",
                "value": "$(StressLevel)"
              },
              {
                "title": "Incident timestamp ($(Timezone)):",
                "value": "$(Timestamp)"
              }
            ]
          },
		  {
            "type": "TextBlock",
            "text": "Columns involved in this incident:$(ListOfColumns:"\nColumn:$(Column),
				ValueBefore:$(ColumnValueBefore),
				ValueAfter:$(ColumnValueAfter),
				On ($(Timezone)):$(ColumnTimestamp),
				Threshold crossed:$(ColumnCrossedThreshold)")",
            "wrap": true
          },
        ]
      }
    ]
  }  
}
   ]
}' -HttpHeaders '{
   "Authorization":"access_token",
   "Content-Type":"application/json",
   "Source":"$(TriggerName)"
}'
```

| Parameters | Description | Required |
| --- | --- | --- |
| -Name | Name of the template | Yes |
| -Type | Type of template | Yes |
| -Body | Body of template | No |
| -Subject | Subject line of template | No |
| -HttpHeaders | Headers of template | No |
| -Source | Built-in or custom source of template. | No |
| -DisableJSONValidation | If you use this parameter, JSON validation will be disabled. | No |

#### Update-CUTriggerTemplate

Updates the properties of a specific trigger template, except for the ID.

```powershell
Update-CUTriggerTemplate
-Id <string>
-Name <string>
-Body <string>
-Subject <string>
-HttpHeaders <string>
-DisableJSONValidation <string>
```

Update Name, Body, and Subject of general template example:

```powershell
Update-CUTriggerTemplate -Id  d0e2f4b6-c1aa-464c-b2d8-9bf397ba1098 -Name '@QA-General -STRESS_UPDATED' -Body 'UPD!
Your monitored resource has crossed a configured Stress Level threshold.
	#Organization Name: $(OrgName)

	#Folder name: $(CUFolderName)

	#Reported by: $(ReportedBy)

	#Trigger name: $(TriggerName)

	Resource name: $(ObjectName)

	Resource type: $(ResourceType)

	=> Stress Level: $(StressLevel) <=

	Incident timestamp ($(Timezone)): $(Timestamp)

	Counters involved in this incident:

$(ListOfColumns:"		Counter: $(Column)

		Severity Level: $(ColumnSeverityLevel)

		Since ($(Timezone)): $(ColumnTimestamp)

		Threshold crossed: $(ColumnCrossedThreshold)")' -Subject 'UPD___STRESS >> ControlUp alert mail - $(TriggerType) - $(Object)'
```

Update Name, Body, and HttpHeaders of webhook template example:

```powershell
Update-CUTriggerTemplate -Id  bd7903a3-f49c-43f1-b478-26a50f4e32b5 -Name 'nnnn@QA-Webhook02' -Body '{
   "templateName":"---nnnn@QA-Webhook02",
   "type":"message",
   "attachments":[
	  {
  "contentType": "application/vnd.microsoft.card.adaptive",
  "content": {
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "type": "AdaptiveCard",
    "version": "999",
    "body": [
      {
        "type": "Container",
        "items": [
          {
            "type": "FactSet",
            "facts": [
              {
                "title": "Organization Name:",
                "value": "$(OrgName)"
              },
              {
                "title": "Folder name:",
                "value": "$(CUFolderName)"
              },
              {
                "title": "Reported by:",
                "value": "$(ReportedBy)"
              },
              {
                "title": "Trigger name:",
                "value": "$(TriggerName)"
              },
              {
                "title": "Object:",
                "value": "$(Object)"
              },
              {
                "title": "ComputerName:",
                "value": "$(CompName)"
              },
              {
                "title": "Resource name:",
                "value": "$(ObjectName)"
              },
              {
                "title": "Resource type:",
                "value": "$(ResourceType)"
              },
              {
                "title": "Stress Level:",
                "value": "$(StressLevel)"
              },
              {
                "title": "Incident timestamp ($(Timezone)):",
                "value": "$(Timestamp)"
              }
            ]
          },
		  {
            "type": "TextBlock",
            "text": "+Columns involved in this incident:$(ListOfColumns:"\nColumn:$(Column),
				ValueBefore:$(ColumnValueBefore),
				ValueAfter:$(ColumnValueAfter),
				On ($(Timezone)):$(ColumnTimestamp),
				Threshold crossed:$(ColumnCrossedThreshold)")",
            "wrap": true
          },
        ]
      }
    ]
  }  
}
   ]
}' -HttpHeaders '{
   "Authorization":"access_token",
   "Content-Type":"application/json",
   "Source":"$(TriggerName)",
   "Test":"true"
}'
```

| Parameters | Description | Required |
| --- | --- | --- |
| -Id | ID of the template | Yes |
| -Name | Name of the template | No |
| -Body | Body of template | No |
| -Subject | Subject line of template | No |
| -HttpHeaders | Headers of template | No |
| -DisableJSONValidation | If you use this parameter, JSON validation will be disabled. | No |

#### Add-CUTriggerTemplate and Update-CUTriggerTemplate Results

Writes single result object to PowerShell with the following properties:

- Error. In case of failure, the reason will be displayed.
- Success. In case of success, properties will be displayed according to template type. General: ID, Name, Type, Source, Subject ,Body. Webhook: ID, Name, Type, Source, HttpHeaders, Body.

#### Remove-CUTriggerTemplate

Deletes a trigger template. Note that you can't delete a trigger template currently in use.

**Syntax**

```powershell
Remove-CUTriggerTemplate
-Id <string>
```

Delete template example:

```powershell
Remove-CUTriggerTemplate -Id "17155AFE-2F46-4775-B11B-EBC333279243"
```

#### Remove-CUTriggerTemplate Results

Writes single result object to PowerShell with the following properties:

- Error. In case of failure, the reason will be displayed.
- Success. In case of success, trigger is removed and the following message will be displayed: "Template '<TemplateName>' - <TemplateId> was deleted successfully."

#### Get-CUTriggerTemplates

Lists all available trigger templates, including both built-in and custom templates, or specific trigger templates. Note that running this cmdlet without any parameters returns results listing all local and community templates in your organization, including general and RESTful API (webhook) types.

**Syntax**

```powershell
Get-CUTriggerTemplates [[-Source] {Unknown | Default | Custom}] [[-Type] {Unknown | General | WebHook}] [[-Name] <string>] [[-TemplateId] <string>]
```

List only default templates example:

```powershell
Get-CUTriggerTemplates -Source Default
```

List only custom templates example:

```powershell
Get-CUTriggerTemplates -Source Custom
```

List only general type templates example:

```powershell
Get-CUTriggerTemplates -Type General
```

List template by template ID example:

```powershell
Get-CUTriggerTemplates -TemplateId "2b290d9b-de34-44f6-a5a8-68684cf188b3"
```

List templates with multiple parameters example:

```powershell
Get-CUTriggerTemplates -Type General -Source Custom -Name "RMK_"
```

| Parameters | Description | Required |
| --- | --- | --- |
| -Source | Built-in or custom source of template | No |
| -Type | Type of template | No |
| -Name | Name of the template | No |
| -TemplateId | ID of the template | No |

#### Get-CUTriggerTemplates Results

Writes multiple result objects to PowerShell with the following properties:

- Error. In case of failure, the reason will be displayed.
- Success. In case of success, returns list of templates with the following properties:

PowerShellPowerShell 

```powershell
-Id <string>
-Name <string>
-Type <string>
-Source <string>
-Body <string>
-Subject <string> General type only
-HttpHeaders <string> WebHook type only
```

List only general type results example:

```powershell
Id      : 5D9F6047-6400-46E7-894A-BBAD85F39060
Name    : ControlUp Windows Event Trigger
Type    : General
Source  : Default
Subject : ControlUp alert mail - $(TriggerType) - $(Object)
Body    : A windows event log entry was recorded on one of your monitored computers.
          Organization Name: $(OrgName)
          
          TriggerName: $(TriggerName)
          
          Computer name: $(FQDN)
          
          Event Source: $(EventSource)
          
          Event Type: $(EventType)
          
          Event ID: $(EventID)
          
          User: $(Username)
          
          Full Message: $(EventFullMsg)
          
          Incident timestamp ($(Timezone)): $(Timestamp)
```
