# Get-MSMQOutgoingQueue

**URL:** <https://forums.powershell.org/t/get-msmqoutgoingqueue/16691>\
**Category:** PowerShell Help\
**Created:** [May 31, 2021, 6:48am UTC](https://forums.powershell.org/t/get-msmqoutgoingqueue/16691 "2021-05-31T06:48:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![itamarka](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@itamarka](https://forums.powershell.org/u/itamarka)\
**Post date:** [May 31, 2021, 6:48am UTC](https://forums.powershell.org/t/get-msmqoutgoingqueue/16691/1 "2021-05-31T06:48:26Z")

</div>

Hi,  
I am running this command PS C:\> Get-MsmqOutgoingQueue -Name “Order\*” | Clear-MsmqOutgoingQueue To clear Outgoing queue.  
I want to clear only those queue that have a state MQ\_QUEUE\_STATE\_NONACTIVE or MQ\_QUEUE\_STATE\_WAITING.  
The output of Get-MsmqOutgoingQueue is:  
DestinationQueueFormatName : DIRECT=OS:Maasw53.cloudsfer.com\private$\MaaS.Backend.Planner.3  
MessageCount : 5  
BytesInQueue : 12700  
UnacknowledgedMessageCount : 0  
UnprocessedMessageCount : 0  
ConnectionHost : maasw51  
NextHops :  
Transactional : MQ\_XACT\_STATUS\_UNKNOWN  
Foreign : STATUS\_UNKNOWN  
EodFirstNonAck : System.\_\_ComObject  
EodLastNonAck : SeqID: 6963899006397186076 SeqNo: 0 PrevNo: 0  
EodLastAck : SeqID: 6963899006397186076 SeqNo: 8909 PrevNo: 0  
EodNextSeq : SeqID: 6963899006397186076 SeqNo: 8915 PrevNo: 8914  
EodLastAckCount : 1  
EodLastAckTime :  
EodNoAckCount : 0  
EodNoReadCount : 0  
EodResendCount : 1  
EodResendInterval : 30000  
EodResendTime :  
State : MQ\_QUEUE\_STATE\_NONACTIVE  
Who do I modify the script?

Thanks

---

<div class="post-metadata">

**Author:** ![matt-bloomfield](https://avatars.discourse-cdn.com/v4/letter/m/dec6dc/32.png) [@matt-bloomfield](https://forums.powershell.org/u/matt-bloomfield)\
**Post date:** [May 31, 2021, 11:22am UTC](https://forums.powershell.org/t/get-msmqoutgoingqueue/16691/2 "2021-05-31T11:22:07Z")

</div>

Hi, welcome to the forum 👋

Please edit your post using the `</>` button to format your code properly. This makes it much easier for people to read and to copy/paste for testing.

I can’t test this but as the cmdlet doesn’t provide any way to filter it sounds like a job for `Where-Object`

`Get-Help Where-Object`

```auto
Get-MsmqOutgoingQueue -Name "Order*" | Where-Object {$_.State -eq 'MQ_QUEUE_STATE_NONACTIVE' -or $_.State -eq 'MQ_QUEUE_STATE_WAITING' | Clear-MsmqOutgoingQueue

```

---

<div class="post-metadata">

**Author:** ![itamarka](https://avatars.discourse-cdn.com/v4/letter/i/9e8a1a/32.png) [@itamarka](https://forums.powershell.org/u/itamarka)\
**Post date:** [May 31, 2021, 12:18pm UTC](https://forums.powershell.org/t/get-msmqoutgoingqueue/16691/3 "2021-05-31T12:18:58Z")

</div>

Thanks, The command works.

---

<div class="post-metadata">

**Author:** ![dotnVo](https://avatars.discourse-cdn.com/v4/letter/d/4af34b/32.png) [@dotnVo](https://forums.powershell.org/u/dotnVo)\
**Post date:** [May 16, 2024, 8:24pm UTC](https://forums.powershell.org/t/get-msmqoutgoingqueue/16691/4 "2024-05-16T20:24:20Z")

</div>

Closed on May 16, 2024, 8:24pm UTC


