• We’re currently investigating an issue related to the forum theme and styling that is impacting page layout and visual formatting. The problem has been identified, and we are actively working on a resolution. There is no impact to user data or functionality, this is strictly a front-end display issue. We’ll post an update once the fix has been deployed. Thanks for your patience while we get this sorted.

Set message queue rights on remote computer with PowerShell

oynaz

Platinum Member
SOLVED: see post #1 by KB

Hi guys,

The software I am supporting needs rights set on message queues on different computers. It is a hassle to set up manually, and errors tend to creep in, so I decided to write (well, copy/paste mostly) a PowerShell script. I works fine if used on a local machine, for instance:

Code:
write-host "Message queue set rights"

Write-Host "... load the .NET Messaging assembly"
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")

$q = New-Object System.Messaging.MessageQueue ".\private$\documenteventhandler"

Write-Host "... check the queue "
Write-Host "    Count: "$q.GetAllMessages().length  -ForegroundColor gray

$q.SetPermissions("Domain Users",
      [System.Messaging.MessageQueueAccessRights]::FullControl,            
      [System.Messaging.AccessControlEntryType]::Set)

However, I want to be able to use the script to set rights on remote copmuters. According to MSDN, system.messaging,messagequeue support a MachineName property, but I cannot figure out how to make it work. I tried, the following, but no luck:

Code:
write-host "Message queue set rights"

Write-Host "... load the .NET Messaging assembly"
[Reflection.Assembly]::LoadWithPartialName("System.Messaging")

$q = New-Object System.Messaging.MessageQueue ".\private$\documentserviceeventhandler"

Write-Host "... check the queue "
Write-Host "    Count: "$q.GetAllMessages().length  -ForegroundColor gray

$q.SetPermissions("Domain Users",
      [System.Messaging.MessageQueue.MachineName]::testmachine, 
      [System.Messaging.MessageQueueAccessRights]::FullControl,            
      [System.Messaging.AccessControlEntryType]::Set)

Can someone help me?
 
Last edited:
Looking at the 4 different SetPermissions functions of the System.Messaging.MessageQueue class I don't see one that alows you to enter a machinename:

http://msdn.microsoft.com/en-us/library/system.messaging.messagequeue(v=vs.110).aspx


BUt it does look like the object contructor does let you do this:

http://msdn.microsoft.com/en-us/library/ch1d814t(v=vs.110).aspx

So your constructor code would change to:


$q = New-Object System.Messaging.MessageQueue "COMPUTERNAME\private$\documentserviceeventhandler"
 
Last edited:
Back
Top