I am trying to allocate additional permissions to a private clustered MSMQ queue.
I found How to set permissions on MSMQ Cluster queues? which is the same problem but I can't get it to work.
The key from that article is to set the environment variable:
$env:_CLUSTER_NETWORK_NAME_ = 'myclusterMSMQ'
But what should myclusterMSMQ
contain?
In my case I have a cluster MSMQCluster
with two nodes MSMQNodeA
and MSMQNodeB
. The queue is in a clustered resource QueueResource
.
The logical to me is to set it to QueueResource
, but when I did that, the permission appeared on a queue with the same name on MSMQNodeA
... this is where I am running my powershell and it is the resource owner - the queue shouldn't be here but during script testing a queue with that name ended up here too.
My code looks like this:
$queueUser= "domain\svc-account"
$queueName=".\private$\log.queue"
$env:_CLUSTER_NETWORK_NAME_ = "$queueResource"
$queue = New-Object System.Messaging.MessageQueue $queueName
$queue.SetPermissions($queueuser, [System.Messaging.MessageQueueAccessRights]::WriteMessage)
I tried a variation that retrieved the queue using GetPrivateQueuesByMachine($queueResource)
but that gave me the error:
System.Messaging.MessageQueueException (0x80004005): The specified format name does not support the requested operation. For example, a direct queue format name cannot be deleted
I am sure that this last method was returning the queue from the QueueResource
because when I listed all queues, I didn't get any of the other garbage queues that are on MSMQNodeA
.
How do I set additional queue permissions on a private clustered queue with Powershell?