Skip to content

Extend PowerShell module with async message handlers and MQTT 5 features#2232

Draft
Copilot wants to merge 8 commits into2186-fr-powershell-compatibilityfrom
copilot/extend-powershell-support
Draft

Extend PowerShell module with async message handlers and MQTT 5 features#2232
Copilot wants to merge 8 commits into2186-fr-powershell-compatibilityfrom
copilot/extend-powershell-support

Conversation

Copy link

Copilot AI commented Feb 7, 2026

Implements the async message handler proposal from #2215 and exposes additional MQTTnet features as PowerShell cmdlets.

Core Implementation

RegisterMqttMessageHandler - Async handler with proper runspace management:

  • Executes ScriptBlock in captured runspace via Task.Run
  • Passes ($topic, $payload, $message) to handler
  • Error output to host stream without blocking event thread
Register-MqttMessageHandler -Session $session -Action {
    param($topic, $payload, $message)
    Write-Host "Received on $topic: $payload (QoS: $($message.QoS))"
}

Connection Enhancements

Connect-MqttSession - Added transport and protocol options:

  • WebSocket: -WebSocketUri "ws://broker:8000/mqtt"
  • TLS: -UseTls -AllowUntrustedCertificates
  • LWT: -WillTopic, -WillPayload, -WillQoS, -WillRetain
  • Tuning: -KeepAlivePeriod, -Timeout

Publishing Enhancements

Publish-MqttMessage - MQTT 5 user properties:

$props = @{ "source" = "PowerShell"; "version" = "1.0" }
Publish-MqttMessage -Session $session -Topic "data" -Payload "test" -UserProperties $props

New Cmdlets

  • Get-MqttSessionStatus - Connection state
  • Test-MqttConnection - Broker ping with timeout
  • Unregister-MqttMessageHandler - Clear all handlers
  • Show-MqttExamples - Quick reference

Documentation

  • README.md with examples and parameter documentation
  • Test.ps1 with comprehensive usage scenarios
  • SmokeTest.ps1 for validation

Total: 13 cmdlets (7 new, 2 enhanced, 4 existing)


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 7 commits February 7, 2026 10:45
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
…TLS, and more features

Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
…tation

Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
Co-authored-by: chkr1011 <6939810+chkr1011@users.noreply.github.com>
Copilot AI changed the title [WIP] Extend support for PowerShell in ticket #2215 Extend PowerShell module with async message handlers and MQTT 5 features Feb 7, 2026
Copilot AI requested a review from chkr1011 February 7, 2026 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Comments