powershell - 如何使用Powershell 2.0将消息发布到ActiveMQ队列?

标签 powershell activemq powershell-2.0

我试图将消息(“mymessage”)发布到ActiveMQ队列(“myqueue”)。在Powershell v3 +中,使用Invoke-WebRequest非常简单。不幸的是,我坚持使用v2。据我所知,这是我需要在v2中复制的Powershell v3中的代码:

$uri = "http://ACTIVEMQ-SERVER:8161/admin/sendMessage.action"

$r = Invoke-WebRequest http://ACTIVEMQ-SERVER:8161/admin/send.jsp -SessionVariable amq

$form = $r.Forms[0]

$form.fields["JMSDestination"] = "myqueue"
$form.fields["JMSPersistent"] = "true"
$form.fields["JMSText"] = "mymessage"

$r = Invoke-WebRequest -Uri $uri -WebSession $amq -Method Post -Body $form.Fields

我当前的尝试如下所示:
$uri1 = [System.Uri]'http://ACTIVEMQ-SERVER:8161/admin/sendMessage.action'
$uri2 = [System.Uri]'http://ACTIVEMQ-SERVER:8161/admin/send.jsp'

$password = ConvertTo-SecureString 'mypassword' -AsPlainText -Force
$credential = New-Object System.Management.Automation.PSCredential('myusername',$password)

$request = [System.Net.WebRequest]::Create($uri2)
$request.method = "GET"
$request.Credentials = $credential

如您所见,我没有取得太大进展。我对Powershell非常陌生,尤其是它的.NET方面。任何帮助将不胜感激。

最佳答案

我知道问这个问题已经很长时间了,但是您看过this吗?
nms或.NET消息传递API库should work

关于powershell - 如何使用Powershell 2.0将消息发布到ActiveMQ队列?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34229219/

相关文章:

powershell - 连接 PowerShell 变量

PowerShell 多个动态参数

powershell - 我可以通过powershell为tightVNC设置密码吗?

java - 防止 ActiveMQ 重新连接失败时自动退出

powershell - Get-AzureRmADServicePrincipal 和 Get-AzureADServicePrincipal 之间有什么区别?

powershell - 使用 powershell 获取当月的天数

c# - PowerShell 与 MongoDB C# 驱动程序的方法不兼容?

grails - 应用程序完全启动后,grails jms开始监听

activemq - 检查 ActiveMQ 中特定队列的可用性?

powershell - 按显示名称而不是 ID 备份 GPO - powershell