【问题标题】:Get remote MSMQ object using 'Get-MsmqQueue' in Powershell 4在 Powershell 4 中使用“Get-MsmqQueue”获取远程 MSMQ 对象
【发布时间】:2016-05-29 11:35:20
【问题描述】:

我正在尝试让 MessageQueue 对象返回,以便通过 Powershell 4.0 cmdlet 向其添加消息:

Get-MsmqQueue

如果我在本地使用消息队列的服务器,我可以运行以下命令并返回 MessageQueue 类型的对象:

Get-MsmqQueue -Name "myQueueName"

现在,如果我在脚本需要存在的另一台服务器上,我似乎无法让 MessageQueue 对象返回。我已经尝试了很多不同的单引号和双引号组合、不同的标志等。

Get-MsmqQueue -Name 'myServerName.myCompany.com\private$\myQueueName'
Get-MsmqQueue -Name 'myServerName\private$\myQueueName'
Get-MsmqQueue -Name 'FormatName:DIRECT=OS:myServerName.myCompany.com\private$\myQueueName'
Get-MsmqQueue -Name 'FormatName:DIRECT=OS:myServerName\private$\myQueueName'
Get-MsmqQueue -Name "FormatName:DIRECT=OS:myServerName\private$\myQueueName"
Get-MsmqQueue -Name 'FormatName:DIRECT=OS:myServerName\private$\myQueueName' -QueueType Private

有没有人幸运地做到了这一点?我非常感谢您的帮助。提前致谢!

【问题讨论】:

  • 遇到同样的问题,请问您找到解决方法了吗?
  • @Sebastian 我没有。我决定另辟蹊径,改用 C#
  • 好的,同样使用 msmq .Net-Assembly 从 msmq 私有远程队列中读取。 get-msmqqueue-cmdlet 似乎存在限制。但是 Send-msmqqueue 正在为远程队列工作。 technet.microsoft.com/en-us/library/dn391725(v=wps.630).aspx 下的详细描述说,send 是唯一接受路径名、格式名和直接格式名的 cmdlet。

标签: windows powershell scripting powershell-4.0


【解决方案1】:

我发现这是可行的:

[System.Reflection.Assembly]::LoadWithPartialName("System.Messaging")
$queuePath = "FormatName:DIRECT=OS:myServerName\private$\myQueueName"
$queue = New-Object System.Messaging.MessageQueue $queuePath

$queue.GetAllMessages()

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-05-23
    • 1970-01-01
    • 1970-01-01
    • 2023-03-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多