I need to setup a Powershell script to periodically delete all emails in a specific Queue ID. I have tried the following and receive errors (following PS line post):
Get-TransportServer | Get-Queue | Get-Message -ResultSize unlimited | where {Queue -eq "<server>\<queueID>"}
| Remove-Message -WithNDR $False
Errors:
Pipeline not executed because a pipeline is already executing. Pipelines cannot be executed concurrently.
+ CategoryInfo : OperationStopped: (Microsoft.Power...tHelperRunspace:ExecutionCmdletHelperRunspace) [],
PSInvalidOperationException
+ FullyQualifiedErrorId : RemotePipelineExecutionFailed
A positional parameter cannot be found that accepts argument '<server>\<queueID>'.
+ CategoryInfo : InvalidArgument: (:) [Get-Queue], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Get-Queue
What am I doing wrong? Manual deletion of the stuck emails is not acceptable, it needs to run on a schedule. Please advise. TIA