[英]How can I cancel & delete a waiting build in the queue using PowerShell
[英]How can I post a message to an ActiveMQ queue using 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方面。 任何幫助將不勝感激。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.