- 04 May 2025
- 2 Minutes to read
- Print
- DarkLight
- PDF
PowerShell Cmdlets to Convert Trigger Filters
- Updated on 04 May 2025
- 2 Minutes to read
- Print
- DarkLight
- PDF
From ControlUp version 9.0.5 and higher, you can run the following PowerShell cmdlets 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. Converts DTO to string.
- Convert-CuTriggerFilterToObject. 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 of the relevant metric(s).
Convert-CuTriggerFilterToString
Convert a trigger filter from a data transfer object (DTO) to a string object.
Syntax
Convert-CuTriggerFilterToString -FilterNodes <TriggerFilterNode>
Example:
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:
$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:
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
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] <string>
Parse and convert to DTO + validating schema example:
$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:
$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:
Update-CUTrigger -TriggerId $addTriggerResult.TriggerId -FilterNodes $triggerFilters