From: Mesan on 10 Jul 2007 11:51 Does anyone have an idea what it takes to administer DB2 through PowerShell? I want to write some scripts to automate my common DB2 management tasks and I'd really like to be able to use PowerShell for that scripting, but I can't find a way to run DB2 comands. I've tried db2cmd /w db2cmd /w /i db2cmd /i (this one got me the closest) db2clpex (looked promising but not so helpfu) It'd really be nice if there were some way I could just register whatever environment variables and whatever else is needed right inside my PowerShell session - that would be ideal. Anyone know how to do that? Thanks, Mesan
From: Jan M. Nelken on 10 Jul 2007 12:41 Mesan wrote: > Does anyone have an idea what it takes to administer DB2 through > PowerShell? I want to write some scripts to automate my common DB2 > management tasks and I'd really like to be able to use PowerShell for > that scripting, but I can't find a way to run DB2 comands. It is relatively very simple: Set environment variable DB2CLP to string **$$** and you can use PowerShell for Db2 commands. Jan M. Nelken
From: Mesan on 10 Jul 2007 13:14 On Jul 10, 9:41 am, "Jan M. Nelken" <Unknown.U...(a)Invalid.Domain> wrote: > Mesan wrote: > > Does anyone have an idea what it takes to administer DB2 through > > PowerShell? I want to write some scripts to automate my common DB2 > > management tasks and I'd really like to be able to use PowerShell for > > that scripting, but I can't find a way to run DB2 comands. > > It is relatively very simple: > > Set environment variable DB2CLP to string **$$** and you can use > PowerShell for Db2 commands. > > Jan M. Nelken Please forgive me, I'm sure I'm making a stupid mistake. Here's what I tried: PS> set %DB2CLP% **$$** PS> db2 connect to mydb DB21061E Command Line Environment not initialized. PS> Just how did you mean for me to set that environment variable? Thanks again for your patience, Mesan
From: Mesan on 10 Jul 2007 13:23 On Jul 10, 10:14 am, Mesan <935m...(a)gmail.com> wrote: > On Jul 10, 9:41 am, "Jan M. Nelken" <Unknown.U...(a)Invalid.Domain> > wrote: > > > Mesan wrote: > > > Does anyone have an idea what it takes to administer DB2 through > > > PowerShell? I want to write some scripts to automate my common DB2 > > > management tasks and I'd really like to be able to use PowerShell for > > > that scripting, but I can't find a way to run DB2 comands. > > > It is relatively very simple: > > > Set environment variable DB2CLP to string **$$** and you can use > > PowerShell for Db2 commands. > > > Jan M. Nelken > > Please forgive me, I'm sure I'm making a stupid mistake. Here's what > I tried: > > PS> set %DB2CLP% **$$** > PS> db2 connect to mydb > DB21061E Command Line Environment not initialized. > PS> > > Just how did you mean for me to set that environment variable? > > Thanks again for your patience, > > Mesan You're a genius! I found some help on using environment variables in powershell and it worked like a champ! Thanks - I just wonder why I was unable to find that tip elsewhere - where did you learn that? For anyone else reading the post - try this: PS> set-item -path env:DB2CLP -value "**$$**" PS> db2 connect to mydb .... it works! Awesome - thanks a ton. Mesan
From: Jan M. Nelken on 10 Jul 2007 13:42
Mesan wrote: > Just how did you mean for me to set that environment variable? > > Thanks again for your patience, One way would be to set it once in <My Computer> (right mouse click to get <Properties>, click on <Advanced> tab, then click on <Environment Variables> (bottom button). Under <System Variables> click <New> and fill form with: Variable name DB2CLP Variable value **$$** This works with DB2 V9.*, for users of DB2 V8.* there is much less elegant solution available as well. Jan M. Nelken |