Active MQ and Powershell - AD Account Provisioning

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.
Who is Participating?
ericreidConnect With a Mentor Commented:

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.
mccarlIT Business Systems Analyst / Software DeveloperCommented:
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.
bnditAuthor Commented:
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.
Protect Your Employees from Wi-Fi Threats

As Wi-Fi growth and popularity continues to climb, not everyone understands the risks that come with connecting to public Wi-Fi or even offering Wi-Fi to employees, visitors and guests. Download the resource kit to make sure your safe wherever business takes you!

mccarlConnect With a Mentor IT Business Systems Analyst / Software DeveloperCommented:
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...
bnditAuthor Commented:
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?
ericreidConnect With a Mentor Commented:
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:

bnditAuthor Commented:
@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
bnditAuthor Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.