Thinking out loud: PowerShell support for DB2?

My PowerShell library for WebSphere MQ has been out for a month or so now, and it seems to have been well-received. I’ve seen a surprising amount of blog posts and news articles about it, the download stats for the SupportPac are very encouraging, and I’m getting a steady (if slowly growing) stream of emails with requests for help and new features.

There is still more to finish with the WMQ library – the biggest piece of outstanding work is adding support for z/OS queue managers, but there are a few other bits and pieces to do as well.

But even so – with my usual attention span of an easily distracted child, I’m starting to look at what I might try next.

I’m thinking a PowerShell extension for DB2 might be a good next step.


  • Like WebSphere MQ, the prospect of writing it is made much easier by the fact that there is already a .NET API and support for building C# applications for DB2
  • Database administration seems to lend itself quite well to PowerShell’s object-oriented nature. Using Select, Where, et al. still reminds me of SQL pretty much every time I type it
  • I know very little about DB2, and it’d be a chance to learn something new

Okay, so my third reason sounds a little weak, but on a personal level, it’s a consideration.

But would there be a demand for supporting DB2 administration using PowerShell? I don’t know… I’ve not heard anyone ask for it, and other than a post on a developerWorks forum, I haven’t been able to find much of a call for it.

Still, it’s an interesting idea.

Tags: , ,

12 Responses to “Thinking out loud: PowerShell support for DB2?”

  1. Andy Piper says:

    It is an interesting idea. Are there existing .NET interfaces to DB2? Worth playing around with, for sure.

  2. […] He is seeking feedback, so if you or someone you know might be interested, please visit this blog post and leave […]

  3. […] mentioned last week that I’m toying with the idea of writing a PowerShell extension for DB2. And one of the first […]

  4. steve says:

    I’m working on a scriptthat wil log into a db but having problems when issueing the db2cmd command. Once I issue that command it appears a new “process” starts and any parameters I’m passing to the script do not get passed along. I tried the solution posted at developerwork forum and it didn’t work for me. Any ideas???

  5. dale says:

    @Steve – Sorry, I’m not sure what you mean. Are you talking about a PowerShell script using db2cmd? What solution at developerWorks have you tried?

  6. steve says:

    I’ve tried this: set-Item -path env:DB2CLP -value **pid#** but it doesn’t seem to work. I’d like to have the powershell script log into a UDB db. Once I issue DB2CMD, db2 starts it’s own process (ie opens a new window) and the other udb commands such as db2 connect to $dbname user $userid using $pwd never execute. I also tried DB2CMD /i, didn’t work. Any help is appreciated. Thanks Dale

  7. steve says:

    I was able to get powershell and UDB to work together w/o setting up any environment variables. From the command prompt (DOS prompt) I typed:
    db2cmd /c powershell c:\myscript.ps1

    myscript.ps1 prompts for a db name, schema name and invokes Powershells get-credential command that I use to capture userid/password to log into a UDB db. Then I issue db2 commands in the script after I log in.

  8. Glenn says:

    I’m curious about db2 and powershell as well. We have recently moved several applications to db2 and this would be very helpful.

  9. Brad says:

    We are running DB2 on Windows and would be very interested in a Powershell library for DB2.

  10. Jonathan says:

    Any recent developments on a PowerShell library for DB2? That’d REALLY be slick. Please? 🙂

  11. dale says:

    Sorry – it’s something I’ve not had a chance to spend any time on.

  12. 935main says:

    A bit of PowerShell love for DB2 would be really nice!