Event Hubs - Send-PSUEvent using custom object?

Hi everybody!

I’m trying to play around with the Event Hubs. Anyone already tried a bit more “complicated” stuff?

Actually I’m trying to do something quite simple though… Instead of passing a simple “string” to the -Data parameter (which accepts an “object”), I’m now trying to send an object that I can use on the connected client.

However I’m not able to figure out how to properly pass the data…

Based on the docs it states that it accepts an object that will be serialized using CLIXML:

So how can I pass an object containing multiple data to the client? :slight_smile:

Right now nothing seems to “arrive” to the client… only if I pass a simple string…

Any help is much appreciated!

Thanks a lot to anybody willing to help :slight_smile:

Here’s my dashboard example to play around…

New-UDForm -Children {
        New-UDTextbox -Id 'message' -Label 'Message'
    } -OnSubmit {
        $obj = [PSCustomObject]@{
            ComputerName = $($EventData.Message)
            Username     = $Secret:rdpuser1.Username
            Password     = $Secret:rdpuser1.Password
        }

# works
        Show-UDToast $obj 

# doesn't seem to work. :-(
        Send-PSUEvent -Hub 'eventhub' -Data $obj 
    }

For anyone interested in how it can be workarounded at the moment, here’s my current “solution”. Like that you can pass the exptected string object which works well on the Client (Event Hub):

        $obj = [PSCustomObject]@{
            ComputerName = $($EventData.Message)
            Username     = $Secret:rdpuser1.Username
            Password     = $Secret:rdpuser1.Password
        }
        $stringobj = $obj | ConvertTo-Csv -UseQuotes Never | Select-Object -Skip 1

        Send-PSUEvent -Hub 'eventhub' -Data $stringobj

On the clientside you then just have to do something like this to work with the CSV string:

    # Take the submitted CSV string and split it in order to have the various values in an array
    $params = $_.split(",")

    # Now continue using the single array values based on your needs
    $remoteServer = $params[0]
    $myuser = $params[1]
    $mypass = $params[2]