Archive

Windows Server

Ever created a lot of nice group policy items and come back to them a year or two later and think “Well where did I apply that firewall rule?” or “Where do I set up servers as Remote Desktop Session hosts?” ?

Powershell saves the day once again.

On a Domain Controller, import the AD Group Policy module

Import-Module GroupPolicy

Then,

Get-GPO -All | ForEach-Object {Get-GPOReport -Guid $_.Id -Path ($_.DisplayName + ".html") -ReportType HTML}

This gives you a nice collection of HTML files in the folder where you executed the script. They will contain the defined elements of your Group Policy item.

This tip is mostly useful in you have large generic GP items like “Windows Server” or “Customer Server”. I have learnt to keep my GP items simple-stupid, like “Firewall Allow TCP 80 Inbound” or “Allow Remote Desktop Connections”

Advertisement

Sometimes you just want a new firewall rule, you know that it doesn’t conflict with anything else and you want it simple.

The solution ? Powershell. Many other pages explain the powershell commands for managing the firewall in detail. For me, that made it harder to memorize what I was actually looking for, so I had to look it up the next time as well. So I decided to write down the simplest of all on this page.

This command will create a new firewall rule allowing incoming TCP connections on port 80 for all profiles:

New-NetFirewallRule -Name allowTcp80 -DisplayName "Allow Inbound Port 80" –LocalPort 80 -Protocol TCP

If you omit -Name a GUID will be assigned as the rule name. When you create a name yourself, it will be easier if you want to do more management from Powershell.

RabbitMQ installation is pretty straightforward except that the data folder is by default located in the User folder of the user performing the uninstall. When user accounts are purged once in a while and all user data are deleted you will also loose your entire RabbitMQ configuration.

Not cool… fortunately, this is easy to configure

So, to start with, grab the latest RabbitMQ installer from http://www.rabbitmq.com/install-windows.html and follow the instructions, install Erlang VM if required.

Choose to install as a Windows Service. When installation is complete, go to services.msc and stop the service.

Now, set up some environment variables, pick a suitable name for you base directory. In my case I use MY_RABBITMQ and point it at E:\rabbitmq. Do not prefix you variable with RABBITMQ_ as it may interfere with RabbitMQ.

System variables:

MY_RABBITMQ=E:\rabbitmq
RABBITMQ_BASE=%MY_RABBITMQ%\base
RABBITMQ_CONFIG_FILE=%MY_RABBITMQ%\rabbitmq
RABBITMQ_LOG_BASE=%MY_RABBITMQ%\logs
RABBITMQ_MNESIA_BASE=%MY_RABBITMQ%\mnesia_base

See http://www.rabbitmq.com/configure.html#customise-windows-environment for more info on RabbitMQ Environment variables.

Now you need to reinstall the RabbitMQ service, as the default paths were set during installation. When you reinstall the RabbitMQ service it will use you newly set environment variables.
1. Create the folder (E:\rabbitmq).
2. Run RabbitMQ Command Prompt as Administrator.
3. If you shell doesn’t point you there directly, go to the sbin folder of you installation (Default C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-x.x.x\sbin on 64-bit operating systems).
4. Run “rabbitmq-service install” (without the quotes). This will also start your service.
5. Install the web management console (requires a service restart).
6. Point your browser to http://localhost:15672 and log in as guest/guest to validate your installation (see how E:\rabbitmq is populated as you go)

C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\sbin>rabbitmq-service install
Creating base directory E:\rabbitmq\base
RabbitMQ service is already present - only updating service parameters

C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\sbin>rabbitmq-plugins enable rabbitmq_management
The following plugins have been enabled:
mochiweb
webmachine
rabbitmq_web_dispatch
amqp_client
rabbitmq_management_agent
rabbitmq_management
Plugin configuration has changed. Restart RabbitMQ for changes to take effect.

C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\sbin>rabbitmq-service stop
C:\Program Files\erl6.1\erts-6.1\bin\erlsrv: Service RabbitMQ stopped.

C:\Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\sbin>rabbitmq-service start
C:\Program Files\erl6.1\erts-6.1\bin\erlsrv: Service RabbitMQ started.

Done !

Note: If you want to make changes to the RabbitMQ configuration file, the active configuration file override is now located at E:\rabbitmq\rabbitmq.config. It is not created by default. RabbitMQ ships with an example config file you may implement your changes in.

C:\>copy "Program Files (x86)\RabbitMQ Server\rabbitmq_server-3.3.5\etc\rabbitmq.config.example" E:\rabbitmq\rabbitmq.config
1 file(s) copied.