February 2019
Intermediate to advanced
626 pages
15h 51m
English
Register-ObjectEvent is used to register interest in an event raised by a .NET object. The command creates a PSEventSubscriber object.
The Register-ObjectEvent command expects at least the name of the object that will be raising the event and the name of the event.
The following FileSystemWatcher instance watches the C:\Data folder. By default, the watcher will only watch for changes at that level, the IncludeSubDirectories property might be changed if this must change. Subscribers are created for the Changed and Created events in the following example:
$watcher = [System.IO.FileSystemWatcher]::new('C:\Data')Register-ObjectEvent -InputObject $watcher -EventName ChangedRegister-ObjectEvent -InputObject ...Read now
Unlock full access