views:

196

answers:

2

I have a powershell script that creates some private queues for me. However, the queues default to being owned by whoever ran the install script. I'd prefer to have them owned by a group (i.e. - Administrators or some such). Anybody know how to do this?

foreach($strQueue in $strQueues) {
  if (![System.Messaging.MessageQueue]::Exists($strQueue)) {
    $q = [System.Messaging.MessageQueue]::Create($strQueue)
    $q.SetPermissions($queueUser, [System.Messaging.MessageQueueAccessRights]::FullControl, [System.Messaging.AccessControlEntryType]::Set)
    $q.SetPermissions("BUILTIN\Administrators", [System.Messaging.MessageQueueAccessRights]::TakeQueueOwnership, [System.Messaging.AccessControlEntryType]::Set)
    Write-Host "... created $strQueue and set FullControl permissions for $queueUser"
  }
}
A: 

I think that taking ownership can be done only from native code ( with the c api of msmq). So no powershell here. But there is a c+ sample here.

Igal Serban
A: 

You could try impersonating a relevant admin account before creating them ... ?

Noon Silk