PowerShell Cmdlets for Trigger Actions

Prev Next

From ControlUp version 9.0.5 and higher, you can run the following PowerShell cmdlets to configure trigger Script-based actions (SBAs) on a machine with a ControlUp Monitor installed:

Add-CUTriggerAction

Adds a new trigger action to an existing trigger.

Syntax 

Add-CUTriggerAction
-TriggerID <Guid>
-Action <AddTriggerActionRequest>

Add a "DumptoDisk" action to trigger example:

Add-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -Action @{TriggerActionType=3
DumpToDisk=@{LocationPath='C:\CONSOLE'
Types='Machines','Sessions'}}

Add a webhook action to trigger example:

Add-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -Action @{TriggerActionType='WebHook'
TemplateId='9585f09b-2889-4c37-b444-d5cd67bd02af'
WebHook=@{
WebHookHttpMethod='Post'
WebHookUri='https://webhook.site/5a6688a8-3c96-443e-82ce-b63c52bf5c4a'}}

Add an email action (to a specific organization member) to trigger example:

Add-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -Action @{TriggerActionType=0
TemplateId='C91C1F34-2225-4291-AAF3-23EA0D99E5FD'
CloudEmail=@{Emailto='user.name@myorg.com'}}

Add an email action (to all organization members) to trigger example:

Add-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -Action @{TriggerActionType=0
TemplateId='C91C1F34-2225-4291-AAF3-23EA0D99E5FD'
CloudEmail=@{Emailto="<All Members>"}}
ParametersDescriptionRequired
-ActionComplex object containing the actions properties to add to this triggerYes
-TriggerIDTrigger IDYes

Update-CUTriggerAction

Updates an existing trigger action.

Syntax

Update-CUTriggerAction
-Action <UpdateTriggerActionRequest>
-triggerActionId <Guid>
-TriggerID <Guid>

Update a "DumptoDisk" action example:

Update-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -TriggerActionId 7c0b10fa-cdb3-45d7-972d-1f93510513e5 -Action @{DumpToDisk=@{LocationPath='C:\Program Files\Smart-X\ControlUpAgent'
Types='Machines'}}

Update a webhook action example:

Update-CUTriggerAction -TriggerId c8e22b52-9af4-411a-8fd2-1d7b6e636f0c -TriggerActionId 06f8eb09-6763-4e6c-b7ee-63be54c3ac21 -Action @{TemplateId='8fdf74c4-4f92-4a13-80ed-f4435047a1c5'
WebHook=@{
WebHookHttpMethod='Get'
WebHookUri='https://webhook.site/5'}}

Update an email action (to a specific organization member) example:

Update-CUTriggerAction -TriggerId c01232b8-1687-4557-867c-55c8cc6b7694 -TriggerActionId 18a2c500-8f89-430d-aa08-1a5ddbe161c3 -Action @{TemplateId='C91C1F34-2225-4291-AAF3-23EA0D99E5FD'
CloudEmail=@{Emailto="user.name@myorg.com"}
resendBehavior=@{interval="00:00:07"
        maxRepetitions=14}}
ParametersDescriptionRequired
-TriggerIDTrigger IDYes
-TriggerActionIdTrigger action IDYes
-ActionAction to update for this triggerYes

Add-CUTriggerAction & Update-CUTriggerAction 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, the cmdlet returns with no output.

Remove-CUTriggerAction

Removes any type of action from any type of existing trigger.

Syntax

Remove-CUTriggerAction [-TriggerId] <guid> [-TriggerActionId] <guid>  

Remove action from trigger example:

Remove-CUTriggerAction -TriggerId a2d3582f-c629-4f4b-b0b4-07c29f320678 -TriggerActionId c30ce88d-da7a-4d63-a121-649a785038fd
ParametersDescriptionRequired
-TriggerActionIdTrigger action IDYes
-TriggerIDTrigger IDYes

Remove-CUTriggerAction 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, the trigger action is removed and the following message will be displayed: "Action '{ActionFriendlyName}' - {ActionId} was deleted successfully for trigger '{TriggerName}' - {TriggerId}."

Get-CUTriggerActions

Lists the available actions configured for a specific trigger.

Syntax

Get-CUTriggerActions [-TriggerId] <guid>

List all actions for a trigger example: 

Get-CUTriggerActions -TriggerId  7f88c98e-d213-422a-b801-9921e6724ac9
ParametersDescriptionRequired
-TriggerIDTrigger IDYes

Get-CUTriggerActions Results

  • Error. In case of failure, the reason will be displayed.
  • Success. In case of success, writes multiple result objects to PowerShell with the following properties:
-templateId <string>
-friendlyName <string> 
-resendBehavior <TriggerActionResendBehavior>
-triggerActionId <Guid> 
-triggerActionType <enum>
-AddObjectNameToSubject <boolean>
-AddTriggerNameToSubject <boolean>
-CloudEmail <CloudEmailTriggerActionSettings>
-DumpToDisk <DumpToDiskTriggerActionSettings>
-RecordEventLog <RecordEventLogTriggerActionSettings>
-SmtpEmail <SmtpEmailTriggerActionSettings>
-ScriptAction <ScriptActionTriggerActionSettings>
-WebHook <WebHookTriggerActionSettings>

Results example: Powershell window displaying Get-CUTriggerActions cmdlet output results

Get-CUTriggerScripts

Lists all scripts that are available to be added as SBAs to triggers. Doesn't list scripts that can't be added to triggers. Note that running Get-CUTriggerScripts without any parameters returns results listing all scripts added to your organization and selected as automated actions. 

Syntax

Get-CUTriggerScripts
 [[-Name] <string>] [[-RecordType] {None | RDPCnnection | Hosts | HFolder | Hypervisor | Folder | MachineExtention | HRFolder | Organization | Machine |
    ManagedHost | XDFolder | XDSite | Session | MachinesAndSession | XDRFolder | XDVDA | XDSession | Process | ProcessAndSession | XDBroker | AWSFolder | AWSConnection | Account |
    Datastore | DSHA | MachinesAndDSHA | VDisk | DSHAAndVDisk | DSDSHAAndVDisk | ProcessGroup | LogicalDisk | ProcessAndLogicalDisk | ProcessAndSessionAndLogicalDisk |
    ProcessAndLogicalDiskAndVDisk | ProcessAndSessionAndLogicalDiskAndVDisk | EventLogEntry | CitrixLicensing | ProcessAndSessionAndLogicalDiskAndCTXLic |
    ProcessAndSessionAndLogicalDiskAndCTXLicAndVDisk | FolderDrillDown | HyperFolderDrillDown | AWSComputer | BrowserURL | XDUser | XDApplicationInstance | XDPublishedApplications |
    XDSiteUser | NetScaler | LoadBalancer | LBServiceGroup | LBService | LBServiceGroupAndLBService | HDXSession | Gateway | STA | NIC | NetScalerDrillDown |
    NetScalerFolderDrillDown | RootFolderDrillDown | NetScalerFolder | LinuxDCFolder | LinuxDC | vSan | Association | CloudConnector | AzureConnection | AzureResourceGroup |
    FolderContainer | TreeContainer | AzureComputer | AzureDisk | AvdHostPool | AvdUserSession | AvdWorkspace | AvdApplicationGroup | AvdRemoteApp | FsLogixDisk | Service | Monitor
    | Site | NetworkDrives}]

List all scripts with record type example:

Get-CUTriggerScripts -RecordType Machine

List all scripts with name and record type example:

Get-CUTriggerScripts  -Name SCCM -RecordType Machine
ParametersDescriptionRequired
-NameName of the trigger scriptNo
-RecordTypeType of record associated with the trigger script.No

Get-CUTriggerScripts Results

  • Error. In case of failure, the reason will be displayed.
  • Success. In case of success, returns list of all scripts you can configure to use for a specific trigger with the following properties:
-ID <script ID/instruction ID> 
-Name <script name> 
-RecordType <eEntityType>
-LastEditor <user name of the last editor of script>

List all scripts with Machine record type results example:

Powershell window displaying Get-CUTriggerScripts cmdlet output resultsImage Caption