externalLibs/Carbon/Carbon/MSMQ/Install-Msmq.ps1
# Copyright 2012 Aaron Jensen # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. function Install-Msmq { <# .SYNOPSIS Installs Microsoft's Message Queueing system/feature. .DESCRIPTION Microsoft's MSMQ is *not* installed by default. It has to be turned on manually. This function will enable the MSMQ feature. There are two sub-features: Active Directory integration and HTTP support. These can also be enabled by setting the `ActiveDirectoryIntegration` and `HttpSupport` switches, respectively. If MSMQ will be working with queues on other machines, you'll need to enable DTC (the Distributed Transaction Coordinator) by passing the `DTC` switch. This function uses Microsoft's feature management command line utilities: `ocsetup.exe` or `servermanagercmd.exe`. **A word of warning**, however. In our experience, **these tools do not seem to work as advertised**. They are very slow, and, at least with MSMQ, we have intermittent errors installing it on our developer's Windows 7 computers. We strongly recommend you install MSMQ manually on a base VM or computer image so that it's a standard part of your installation. If that isn't possible in your environment, good luck! let us know how it goes. If you know better ways of installing MSMQ or other Windows features, or can help us figure out why Microsoft's command line installation tools don't work consistently, we would appreciate it. .EXAMPLE Install-Msmq Installs MSMQ on this meachine. In our experience, this may or may not work. You'll want to check that the MSMQ service exists and is running after this. Please help us make this better! .EXAMPLE Install-Msmq -HttpSupport -ActiveDirectoryIntegration -Dtc Installs MSMQ with the HTTP support and Active Directory sub-features. Enables and starts the Distributed Transaction Coordinator. #> [CmdletBinding(SupportsShouldProcess=$true)] param( [Switch] # Enable HTTP Support $HttpSupport, [Switch] # Enable Active Directory Integrations $ActiveDirectoryIntegration, [Switch] # Will MSMQ be participating in external, distributed transactions? I.e. will it be sending messages to queues on other machines? $Dtc ) $optionalArgs = @{ } if( $HttpSupport ) { $optionalArgs.MsmqHttpSupport = $true } if( $ActiveDirectoryIntegration ) { $optionalArgs.MsmqActiveDirectoryIntegration = $true } Install-WindowsFeature -Msmq @optionalArgs if( $Dtc ) { Set-Service -Name MSDTC -StartupType Automatic Start-Service -Name MSDTC $svc = Get-Service -Name MSDTC $svc.WaitForStatus( [ServiceProcess.ServiceControllerStatus]::Running ) } } |