6

Is there any way of doing this through a batch or powershell script? I'm looking for a way to set up several new servers.

The only thing I found on the subject leads me to believe you cannot: from :http://technet.microsoft.com/en-us/library/cc785060.aspx

The message store location must only be modified using the Storage tab, in Computer Management, Services and Applications, Message Queuing properties.

Edit - I also found this article. It lists some registry values, but again advises against it http://blogs.msdn.com/b/johnbreakwell/archive/2009/02/09/changing-the-msmq-storage-location.aspx

Hugo Forte
  • 161
  • 5
  • Microsoft claims that PowerShell can do everything the UI can. Whether or not that's true in this instance is probably a coin flip. – Hyppy Dec 18 '14 at 16:18
  • Mess with `HKLM\SOFTWARE\Microsoft\MSMQ\Parameters` - restart msmq service - profit!!! – Mathias R. Jessen Dec 18 '14 at 17:34
  • 1
    In the comments to my blog post you're referencing, there's the following from Randy Ridgely: "Starting with Windows 8, there is a PowerShell cmdlet that supports this: Set-MsmqQueueManager. There are options to change the MsgStore, LogMsgStore and TransactionLogStore. You can use get-help Set-MsmqQueueManager -detailed at a PowerShell prompt for more information." – John Breakwell Feb 01 '15 at 23:13

1 Answers1

2

Source: http://www.erbrech.com/blog/2016/05/29/Move-msmq-storage-location-with-powershell-and-Desired-State-Configuration.html

$Location = 'E:\msmq\storage'

If(!(test-path $Location))
{
     New-Item -ItemType Directory -Force -Path $Location
}

takeown /F $Location /R /D y #this should give me ownership of both msmq and LQS folder
icacls $Location /reset /T /C
icacls $Location "/grant:r" "NT AUTHORITY\NetworkService:(OI)(CI)(M)" /T /C
$ConfirmPreference = 'None'

Set-MsmqQueueManager -MsgStore $Location -TransactionLogStore $Location -MsgLogStore $Location

Start-Service MSMQ
Matt Canty
  • 121
  • 5