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:
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:
Can someone help me?
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: