How to set permissions on MSMQ Cluster queues?

Posted by JorgeSandoval on Stack Overflow See other posts from Stack Overflow or by JorgeSandoval
Published on 2012-04-05T01:14:59Z Indexed on 2012/06/29 21:16 UTC
Read the original article Hit count: 528

Filed under:
|
|

I've got a cluster with functioning private MSMQ 3.0 queues. I'm trying to programmatically set the permissions, but can't seem to connect via System.Messaging on the queues. The code below works just fine when working with local queues (and using .\ nomenclature for the local queue). How to programmatically set the permissions on the clustered queues?

Powershell code executed from the active node

function set-msmqpermission ([string] $queuepath,[string] $account, [string] $accessright)
{
    if (!([System.Messaging.MessageQueue]::Exists($queuepath))){
    throw "$queuepath could not be found."
}
$q=New-Object System.Messaging.MessageQueue($queuepath)
$q.SetPermissions($account,[System.Messaging.MessageQueueAccessRights]::$accessright,            
  [System.Messaging.AccessControlEntryType]::Set)
}
set-msmqpermission "clusternetworkname\private$\qa1ack" "UserAccount" "FullControl"

Exception calling "SetPermissions" with "3" argument(s): "Invalid queue path name." At line:30 char:19 + $q.SetPermissions <<<< ($account,[System.Messaging.MessageQueueAccessRights]::$accessright,
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException

© Stack Overflow or respective owner

Related posts about powershell

Related posts about msmq