The PowerShell Listen operation executes a given PowerShell script and notifies the containing operation list about changes whenever it writes to the progress data stream.

Technical Requirements

There are a number of technologies that the PowerShell Script is dependant on. Specifically:

  1. PowerShell needs to be installed on the host machine of the MIM Event Broker Service installation


This PowerShell Listen operation can be used to complement the PowerShell Changes or any of several other changes operations to improve the timeliness of change notification.

The containing operation list will execute whenever the PowerShell script writes to the progress data stream, which can be done in the following manner:

Write-Progress "<Activity name goes here>";

The activity name will not affect the performance of the operation, but will appear in log messages so it can be convenient to use something meaningful.


In addition to the common listen operation configuration settings shared by all Listen Operations, the LDAP Listen operation requires the following by way of configuration:

Name Description
Script The PowerShell script to be executed - see this for more details on implementation of PowerShell scripts.


The following are a few examples to get started:

Example 1

Changes have occurred whenever a TCP client connects to a particular port

$host = "";$port = 5252;
$listener = New-Object System.Net.Sockets.TcpListener([System.Net.IPAddress]::Parse($host), $port);
while ($true)
    $listener.AcceptClient().Close(); # blocking call
    Write-Progress "Progress";

Example 2

Changes have occurred whenever a change is made to a particular file

$folder = "C:\Program Files\AddressBook";$file = "entries.txt";
$fsw = New-Object IO.FileSystemWatcher $folder, $file -Property @{NotifyFilter = [IO.NotifyFilters]'LastWrite'};
Register-ObjectEvent $fsw Changed -SourceIdentifier FileChanged -Action { Write-Progress "Progress"; };
# keep script alive so that we can unregister when disabled
    while ($true) { Start-Sleep 5; }
    Unregister-Event FileChanged;
PowerShell Operation Listen Operation

Is this article helpful for you?