--- title: "PowerShell Cmdlets to Convert Trigger Filters" slug: "powershell-cmdlets-to-convert-trigger-filters" updated: 2025-05-04T12:28:34Z published: 2025-05-04T12:28:34Z canonical: "support.controlup.com/powershell-cmdlets-to-convert-trigger-filters" --- > ## 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 to Convert Trigger Filters From ControlUp version 9.0.5 and higher, you can run the following [PowerShell cmdlets](/v1/docs/powershell-cmdlets-for-triggers) to configure trigger filter conditions either as custom data transfer objects (DTO) that you export to JSON format, or as a more intuitive string object: - [Convert-CuTriggerFilterToString](/v1/docs/powershell-cmdlets-to-convert-trigger-filters#convertcutriggerfiltertostring). Converts DTO to string. - [Convert-CuTriggerFilterToObject](/v1/docs/powershell-cmdlets-to-convert-trigger-filters#convertcutriggerfiltertoobject). Converts string to DTO. Use these cmdlets to add new triggers or to update existing triggers on a machine with a ControlUp Monitor installed. To configure filter conditions, you must know the [field name](/v1/docs/monitor-cluster-powershell-fields-by-table) of the relevant metric(s). #### Convert-CuTriggerFilterToString Convert a trigger filter from a data transfer object (DTO) to a string object. **Syntax** ```powershell Convert-CuTriggerFilterToString -FilterNodes ``` **Example:** ```powershell Convert-CuTriggerFilterToString -FilterNodes @{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='CPU' Value='25' ComparisonOperator='GreaterThan' }},@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='ActiveMemory' Value='104857600' ComparisonOperator='GreaterThanOrEqual' }},@{LogicalOperator='Or' ChildNodes=@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='oActiveSessions' Value=9 ComparisonOperator='GreaterThan' }},@{LogicalOperator='And' IsNegation=$true ExpressionDescriptor=@{ Column='TotalProcesses' Value=333 ComparisonOperator='GreaterThan' }},@{LogicalOperator='Or' IsNegation=$true ExpressionDescriptor=@{ Column='sName' Value='*Test*' ComparisonOperator='Equal' }} } ``` Filter matching a Stress/Machine record type example: ```powershell $filterStr = Convert-CuTriggerFilterToString -FilterNodes @{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='CPU' Value='25' ComparisonOperator='GreaterThan' }},@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='ActiveMemory' Value='104857600' ComparisonOperator='GreaterThanOrEqual' }},@{LogicalOperator='Or' ChildNodes=@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='oActiveSessions' Value=9 ComparisonOperator='GreaterThan' }},@{LogicalOperator='And' IsNegation=$true ExpressionDescriptor=@{ Column='TotalProcesses' Value=333 ComparisonOperator='GreaterThan' }},@{LogicalOperator='Or' IsNegation=$true ExpressionDescriptor=@{ Column='sName' Value='*Roman*' ComparisonOperator='Equal' }} },@{LogicalOperator='Or' IsNegation=$true ChildNodes=@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='Description' Value='*XXX*' ComparisonOperator='Equal' }},@{LogicalOperator='Or' IsNegation=$false ExpressionDescriptor=@{ Column='sName' Value='*YYY*' ComparisonOperator='Equal' }},@{LogicalOperator='Or' IsNegation=$false ChildNodes=@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='UptimeInDays' Value=99 ComparisonOperator='GreaterThan' }},@{LogicalOperator='And' IsNegation=$false ExpressionDescriptor=@{ Column='sOSCaption' Value='*2019*' ComparisonOperator='Equal' }} } } $filterStr ``` | Parameters | Description | Required | | --- | --- | --- | | -FilterNodes | Filter nodes to apply to the trigger | Yes | #### Convert-CuTriggerFilterToObject Results Writes single result object to PowerShell with the following properties: ```powershell PS C:\Users\romank> $filterStr CPU -gt 25 AND ActiveMemory -ge 104857600 OR (oActiveSessions -gt 9 AND NOT TotalProcesses -gt 333 OR NOT sName -eq "*Roman*") OR NOT (Description -eq "*XXX*" OR sName -eq "*YYY*" OR (UptimeInDays -gt 99 AND sOSCaption -eq "*2019*")) ``` #### Convert-CuTriggerFilterToObject Parse and convert trigger filter conditions from a string object to a DTO. **Syntax** ```powershell Convert-CuTriggerFilterToObject [-RecordType] {Folder | Machine | Session | Process | Service | Account | Application | Host | Datastore | DatastoreOnHost | VirtualDisk | LogicalDisk | FsLogixDisk | NetScaler | LoadBalancer | LbServiceGroup | LbService | Gateway | Nic | Sta | CitrixLicensing | AvdHostPool | AvdWorkspace | AvdApplicationGroup | Events} [-Filter] ``` **Parse and convert to DTO + validating schema example:** ```powershell $triggerFilters = Convert-CuTriggerFilterToObject -RecordType Machine -Filter 'NetBios -eq "SomeTestMachine" AND (iCPUCount -gt 1 OR GPUAvailableMemory -ge 2Gb)' ``` Filter matching a Stress/Machine record type example: ```powershell $filterObj = Convert-CuTriggerFilterToObject -RecordType Machine -Filter 'CPU -gt 25 AND ActiveMemory -ge 104857600 OR (oActiveSessions -gt 9 AND NOT TotalProcesses -gt 333 OR NOT sName -eq "*Roman*") OR NOT (Description -eq "*XXX*" OR sName -eq "*YYY*" OR (UptimeInDays -gt 99 AND sOSCaption -eq "*2019*"))' $filterObj ``` | Parameters | Description | Required | | --- | --- | --- | | -RecordType | Type of trigger record | Yes | | -Filter | Filter to apply to the trigger | Yes | #### Convert-CuTriggerFilterToObject 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, returns the syntax of the string you converted to DTO. After successful conversion, you can update the trigger with the filter conditions you converted to DTO using the following cmdlet: ```powershell Update-CUTrigger -TriggerId $addTriggerResult.TriggerId -FilterNodes $triggerFilters ```