1 year ago

#331226

test-img

Carsten

How to setup a permanent WMI subscription which includes a dynamic condition?

I want to create a permanent WMI subscription to start a script every time a defined trigger gets fired. Here I would like to react when the Citrix RTT is above a given threshold. Here a regular PS-code sample to get that RTT data (with a filter in line 2):

$sid = [System.Diagnostics.Process]::GetCurrentProcess().SessionId
$rtt = Get-WmiObject -Namespace 'Root\Citrix\EUEM' -Class 'Citrix_Euem_RoundTrip' -Filter "SessionID=$sid"

Now when I want to define a permanent WMI subscription I am struggling to setup the correct filter-condition like shown in the above code. Here a sample for a filter:

$filter   = [wmiclass]"root\subscription:__EventFilter"

$f1 = $filter.CreateInstance()
$f1.Name = "CitrixEvent"
$f1.EventNamespace = "root\Citrix\EUEM"
$f1.QueryLanguage = "WQL"
$f1.Query = "SELECT * FROM __InstanceModificationEvent WITHIN 10 WHERE TargetInstance ISA ""Citrix_Euem_RoundTrip"" GROUP WITHIN 10"
[void]$f1.Put()

Problem here is, that I dont know how to filter by the correct SessionID. Is that possible at all with the WQL-syntax? I do not want to react on an event which is related to a different session.

powershell

citrix

wql

0 Answers

Your Answer

Accepted video resources