The Receive-MsmqQueue cmdlet does a destructive read from a queue.
The cmdlet returns the received System.Messaging.Message object.
This cmdlet accepts values for the Name parameter of path names, format names, and direct format names.
Some other Message Queuing (also known as MSMQ) cmdlets require a friendly name for the queue.
If you specify the Peek parameter, the cmdlet peeks at the message instead of doing a destructive read.
The cmdlet succeeds if it returns at least one message.
If you specify the Peek parameter, this cmdlet returns the number of messages that is the minimum of the number supplied by the Count parameter and the number of messages in the queue.
This command gets the specified queue by using the Get-MsmqQueue cmdlet.
The command passes the result to the current cmdlet by using the pipeline operator.
The current cmdlet performs a transacted read on the queue.
Parameters
-Count
Specifies the number of messages to be returned.
The default value is 1.
You must specify a value larger than 0.
Parameter properties
Type:
Int32
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-InputObject
Specifies a MessageQueue object.
The cmdlet reads from the queue that the MessageQueue specifies.
This parameter accepts pipeline input.
Parameter properties
Type:
MessageQueue
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
True
Value from pipeline:
True
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Peek
Indicates that this cmdlet returns a copy of the first message in the queue without removing the message from the queue.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Peek
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-RetrieveBody
Indicates that this cmdlet returns the body of the message.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Timeout
Specifies the maximum time, in milliseconds, to wait for the queue to contain a message.
The default value is 0.
Parameter properties
Type:
TimeSpan
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
(All)
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
-Transactional
Indicates that the cmdlet performs a transacted receive.
Parameter properties
Type:
SwitchParameter
Default value:
None
Supports wildcards:
False
DontShow:
False
Parameter sets
Transactional
Position:
Named
Mandatory:
False
Value from pipeline:
False
Value from pipeline by property name:
False
Value from remaining arguments:
False
CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.