Tag: poshrunner

I’ve been periodically hacking away at PoshRunner. I have lots of plans for it. Some of these are rewriting some of it in C++, allowing you to log output to MongoDB and total world domination! However, today’s news is not as grand.

Usage: poshrunner.exe [OPTION] [...]
Options:
--appdomainname=NAME Name to give the AppDomain the PowerShell script executes in.
--config=CONFIGFILE The name of the app.config file for the script. Default is scriptName.config
-f SCRIPT, --script=SCRIPT Name of the script to run.
-h, --help Show help and exit
--log4netconfig=LOG4NETCONFIGFILE Override the default config file for log4net.
--log4netconfigtype=LOG4NETCONFIGTYPE The type of Log4Net configuration.
--shadowcopy Enable Assembly ShadowCopying.
-v, --version Show version info and exit

I have a tendency to do odd things with technology so that things don’t just work. When I point out the obscure edge cases I find, most people tell me, “well don’t do that.” I usually ignore them and dream of tilting windmills. Well today a windmill has been tilted, and this is the epic tale.

Now all this is a lot scarier than it sounds. However, it stops two important groups of people from ever using PowerShell to call DLLs that absolutely require you to manipulate your app.config:

People scared off by the word AppDomain

People that realize they have better things to do than everything I described above

Lucky for these two groups of people, I wasted my time so they didn’t have to! The project is currently called AppDomainPoshRunner, and I ILMerge it (via IL-Repack) into poshrunner.exe. Right now poshrunner takes one command line argument, the path to a script. If the script exists it will run it in an AppDomain whose config file is scriptname.config. Log4net configuration is read from a file called ADPR.log4net.config in the same directory as poshrunner.config.

The full background is to long and convoluted for this post. This was all born out of a problem with calling New-WebServiceProxy twice in the same PowerShell console. I use log4net to write the console messages so this has the potential to be quite extendable. Then Stan needed to run PowerShell scripts from msbuild and was complaining to me about it over twitter. He didn’t like the hacky solution I had then. Eventually I realized this was the way to simplify my previous solution.

So download the zip file. Try it out. Complain to me when you find bugs!