Blog Post

Installing MSMQ using PowerShell

Wednesday, July 5, 2017 5:17 AM

What is this about

Installing MSMQ on local machine/server.

I am doing this because I want to write a console app to read/write into MSMQ. In order to achieve this, I need MSMQ installed on my machine.

I have worked with multiple teams and software developers, who spends too much time manually repeating installation of same software. I want to write something once and only when absolutely necessary modify this. 

How do we install MSMQ using PowerShell?

Installing MSMQ using PowerShell

Criteria for this step:

I want to be able to reproduce the same step everywhere. Therefore I need to be able to script the installation.


The PowerShell

MSMQ installation

First I need to have a list of available packages. I can achieve this by:

Get-WindowsOptionalFeature –Online | ? FeatureName -match "msmq" | select FeatureName

When we execute the command above, we will receive following output 



Second, I need to install the feature selected feature

Enable-WindowsOptionalFeature -Online -FeatureName MSMQ-Server


The output for this can be as follows: 

Enable-WindowsOptionalFeature : One or several parent features are disabled so current feature can not be enabled.
At line:5 char:1
+ Enable-WindowsOptionalFeature -Online -FeatureName MSMQ-Server
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Enable-WindowsOptionalFeature], COMException


The issue was as we could read from the command above some parent features are not enabled and therefore we cannot install our chosen feature. We can fix this using switch ALL. This means that all features required will be enabled/installed as part of an installation of the feature.


Enable-WindowsOptionalFeature -Online -FeatureName MSMQ-Server -All

 After executing the full command we will get nice output as follows

Path : 
Online : True
Restart Needed : False


We went through two PowerShell commands showing us, how to get the list of features available to install on our system and command how to install feature when we have parent features installed or missing.

I hope you have fount this useful.

Error pages
Links and tools