Register-EngineEvent - MessageData is empty - by Shay Levi

Status : 

 


8
0
Sign in
to vote
ID 775898 Comments
Status Active Workarounds
Type Bug Repros 4
Opened 1/5/2013 11:42:17 PM
Access Restriction Public

Description

With Register-ObjectEvent I can pass a value in the MessageData parameter and get it when the event triggers (MessageData 42).


PS> $timer  = New-Object Timers.Timer
PS> $timer.Interval = 500
PS> $job = Register-ObjectEvent -InputObject $timer -EventName Elapsed -SourceIdentifier Timer.Random -MessageData 42 -Action { $event | fl * }
PS> $timer.Enabled = $true

PS> Receive-Job $job

ComputerName     :
RunspaceId       : 8f50ec1a-0121-43cf-9d7b-a16715c5c3be
EventIdentifier  : 12
Sender           : System.Timers.Timer
SourceEventArgs  : System.Timers.ElapsedEventArgs
SourceArgs       : {System.Timers.Timer, System.Timers.ElapsedEventArgs}
SourceIdentifier : Timer.Random
TimeGenerated    : 1/4/2013 5:13:37 PM
MessageData      : 42



However, MessageData returns empty when using the Register-EngineEvent cmdlet 


PS> Register-EngineEvent -SourceIdentifier foo -MessageData 42 -Action { $event.MessageData }
PS> New-Event -SourceIdentifier foo
 
ComputerName     : 
RunspaceId       : 27ba0e03-ff61-4958-9d6f-ab3a19359141
EventIdentifier  : 7
Sender           : 
SourceEventArgs  : 
SourceArgs       : {}
SourceIdentifier : foo
TimeGenerated    : 24/12/2012 12:47:39
MessageData      : 

Sign in to post a comment.