Active MQ and Powershell - AD Account Provisioning

Posted on 2013-01-30
Medium Priority
Last Modified: 2013-03-06
I don't have much experience with Active MQ http://activemq.apache.org/ 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 36

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 36

Assisted Solution

mccarl earned 668 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...


Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.


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 C#....so as far as I understand it, it is possible to run C# code within powershell, correct?

Assisted Solution

ericreid earned 1332 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:  http://www.tech-corner.org/main/2013/02/powershell-and-activemq/


Author Comment

ID: 38939786
@ericreid: very interesting script...you'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 1332 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Group policies can be applied selectively to specific devices with the help of groups. Utilising this, it is possible to phase-in group policies, over a period of time, by randomly adding non-members user or computers at a set interval, to a group f…
Microsoft Office 365 is a subscriptions based service which includes services like Exchange Online and Skype for business Online. These services integrate with Microsoft's online version of Active Directory called Azure Active Directory.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…
Suggested Courses
Course of the Month15 days, 16 hours left to enroll

850 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