Active MQ and Powershell - AD Account Provisioning

Posted on 2013-01-30
Last Modified: 2013-03-06
I don't have much experience with Active MQ and I'd like to know if Powershell can work with Active MQ. Currently, AD accounts using a Java-based system but we would like to change it to Powershell. The AD account provisioning with Powershell is not a problem, but I'm not sure about connecting it to a message broker such as Active MQ.

If you have experience with Active MQ, I'd like to hear your ideas especially if you can tell me whether or not it can work with Powershell.
Question by:bndit
  • 4
  • 2
  • 2
LVL 35

Expert Comment

ID: 38849704
I highly doubt that there would be any "built-in" path to integrate PowerShell with ActiveMQ (or anythign Java based actually).

connecting it to a message broker
What exactly does the integration need to provide? Are we just talking about your PowerShell script send a message to a queue? Or does it need to be more deeply integrated?

If you are just talking about being able to send a message to a queue, then probably the best you will be able to do is have your script call a program (written in Java) that takes the message as a parameter and sends it off to the broker.

Author Comment

ID: 38877256
The integration needs to provide information about new AD accounts created. As of today, ActiveMQ runs as a service on a DC and the Java routine actually triggers a small C# code that actually is the piece that puts the new message into ActiveMQ (working on getting that piece of code so that I can share).

The idea is to create a new AD account, and put that message into the queue for processing (this message is relayed to background processes that are used to populate tables, etc.). My alternative is to export new AD user info to a CSV file, but it's not the preferred route.

It'd seem that as long as I can connect to ActiveMQ (username/password?) and pass the message to it, I should be fine but then again I can't find any info that relates Powershell to ActiveMQ.
LVL 35

Assisted Solution

mccarl earned 167 total points
ID: 38879026
Ok, with what you have written above and me doing some more thinking, the best way might be to use ActiveMQ's REST API. Depending on what version you are running, this is implemented as more of an addon but it has been around for a while and so I would say is fairly stable/usable. I would take a look at the following links to get you started...
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.


Author Comment

ID: 38932653
thx...will definitely look into this suggestion. On a different note....Im trying to get my hands on the piece of code that connects to the message broker so that I can share with you. This code is as far as I understand it, it is possible to run C# code within powershell, correct?

Assisted Solution

ericreid earned 333 total points
ID: 38933906
We have a project going on right now that we needed to do the same thing you are looking for.  I came across this post while doing some searching.  Mccarl's links provided some good information and helped me get the problem solved.

We ended up using PowerShell 3.0 and the Invoke-WebRequest cmdlet to submit data from an XML file to the ActiveMQ server.  I've posted my code on my site if you want to take a look.  Hopefully it will help you with your project as well.

You can find my article here:


Author Comment

ID: 38939786
@ericreid: very interesting're right, that's exactly what I'm looking to do. But, I have a couple of questions

Is Powershell 3.0 a requirement for this to work?
In this line of your code $getADUser = get-aduser -Identity $UserName -Properties *
I don't see where you're assigning a value to $UserName
You create an XML file for each user you create? What do you do with those files once you process them? delete them? move them? I'd imagine that the next time the script run, you wouldnt want to process the same users over again.
Why did you choose to create the XML file you did instead of Export-Clixml?
I dont see where you assign a value to $amq

Accepted Solution

ericreid earned 333 total points
ID: 38940667

I think PowerShell 3.0 has to be used if you want to use the Invoke-WebRequest.  I think that is when that cmdlet was implemented.  I've seen some other examples that I think did something similar in earlier versions, but there were more commands that had to be issued.  So upgrading to PowerShell 3 and using this seemed simpler.

Sorry for not showing the $UserName.  That is a variable that is set earlier in the PowerShell script we use to create our AD accounts.  We pass the user's first and last name to the script manually or through and CSV file and create our $UserName based off of that.

As for creating the XML file, I'm doing this just as a test to prove I could output the AD information in the exact format we wanted.  I'm not sure yet if we will keep those files around or not.  One thought we had was it would be a way to track when users were created and who created them.  Again we may look at doing this slightly different.  The way the script is written right now the XML file is "$UserName.xml" so for me the file would be ereid.xml.  The $UserName variable is still set to ereid until I'm done.  Once the script processes the next name the $UserName variable would change.  The only problem would be if we tried to create a new user with same username as an active account (which we check for before we even start to create the new account).

I tested the Export-Clixml command, but it added some information to the XML file that we didn't want or need.  So I manually built the XML file to contain only the information we needed.  That way the other system that we are doing this for doesn't have to parse through any more that what is needed.  I was just trying to keep the information going between the systems simple and clean.

I'm not using the $amq variable.  That was in the example that I used to make the initial web request.  However, I don't need it because I was able to create the $form variable and read the fields from that array.  I've not done a lot with PowerShell so I just didn't catch that when I was getting rid of some of the other things the example contained.  The example I used to read the ActiveMQ form was based of this TechNet article and Example 2 (logging into Facebook).

Sorry for being long winded.  I hope this helps clear some things up.

As the project I'm doing this for progresses I'll probably be making changes and updating my site.  So feel free to check back there and ask any questions about it here or there and I'll try to help.

Author Closing Comment

ID: 38959030

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
swing controls 2 16
AD and SQL Server 2016 2 28
Append data to an XML file 3 15
windows server 2012 R2 DHCP clustering ? 5 23
This article runs through the process of deploying a single EXE application selectively to a group of user.
Last week, our Skyport webinar on “How to secure your Active Directory” ( provided 218 attendees with a step-by-step guide for…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…
The viewer will learn how to implement Singleton Design Pattern in Java.

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question