Getting Started
What is PowerShell Universal?
Installation
Windows
IIS
Persistent Docker Image
Configuration
Port and HTTPS Certificate
SQL Persistence
Platform
Environments
Variables
Published Folders
Git
Repository
Modules
Secret Management
APIs
Basics
Security
Event Hubs
Automation
Scripts
Scheduling
Triggers
Apps
Basics
Dynamic Regions
Session and Cache
Forms
Navigation
Basic Tables
Designer
Theming
Pages
Forms
Desktop
About
File Associations
Security
Forms
Azure Active Directory and OpenID Connect
Roles
App Tokens
Development
Debugger
Visual Studio Code Extension
PowerShell Module and Management API
Event Hubs
Send events to clients with Event Hubs
Download this Lecture DocsIn this video, we will look at how to send events to clients with Event Hubs.
Code
App
New-UDApp -Content {
<#
Connect-PSUEventHub -ComputerName http://localhost:5000 -Hub 'eventhub' -ScriptBlock {
New-BurntToastNotification -Text $_
}
#>
New-UDForm -Children {
New-UDTextbox -Id 'message' -Label 'Message'
} -OnSubmit {
Send-PSUEvent -Hub 'eventhub' -Data $EventData.Message
Show-UDToast 'Message sent!'
}
<#
$AppToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9uYW1lIjoiYWRtaW4iLCJodHRwOi8vc2NoZW1hcy54bWxzb2FwLm9yZy93cy8yMDA1LzA1L2lkZW50aXR5L2NsYWltcy9oYXNoIjoiNzUzNTEyZDctOTE1Ni00NzkzLThlYzYtYzE1YjE3OTkzMGU3Iiwic3ViIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCIsImh0dHA6Ly9zY2hlbWFzLm1pY3Jvc29mdC5jb20vd3MvMjAwOC8wNi9pZGVudGl0eS9jbGFpbXMvcm9sZSI6IkFkbWluaXN0cmF0b3IiLCJuYmYiOjE2OTUwNzUzNjgsImV4cCI6MTcyNjY5Nzc2OCwiaXNzIjoiSXJvbm1hblNvZnR3YXJlIiwiYXVkIjoiUG93ZXJTaGVsbFVuaXZlcnNhbCJ9.7X9CBrtmvFKu5tEf2pBtSUMXytBm4n5V_GIo9W1BcoU'
[System.Reflection.Assembly]::LoadWithPartialName("Microsoft.VisualBasic.Core")
Connect-PSUEventHub -ComputerName http://localhost:5000 -Hub 'securehub' -ScriptBlock {
[Microsoft.VisualBasic.Interaction]::InputBox($_)
} -AppToken $AppToken
#>
New-UDButton -Text 'Ask' -OnClick {
$Connection = Get-PSUEventHubConnection | Where-Object UserName -EQ 'Admin' | Select-Object -Last 1
$Result = Send-PSUEvent -Hub 'securehub' -Data 'What should be tell the server?' -ConnectionId $Connection.ConnectionId
Show-UDToast $Result
}
}