TL;DR: Use both: https://github.com/beefarino/ScriptCS-PowerShell-Module

A few days ago I posted a teaser of a project I hammered together that allowed you to run ScriptCS inside of your PowerShell session.  This morning I pushed the cleaned-up version to to GitHub: https://github.com/beefarino/ScriptCS-PowerShell-Module.

I’ve been watching ScriptCS with much interest – I’m a huge fan of scripting and REPL interaction and having another environment to leverage makes me happy.  What makes me sad is when I read crap like this on twitter:

ScriptCS is awesome!  <expletive deleted> PowerShell!

Or this:

PowerShell is amazing and ScriptCS is teh suck!

Why anyone would shun one or the other is beyond me.  They each have a wealth of possibility to offer.  My first instinct with new technology is to figure out how to make it work with other things I already know.  This helps me understand the guts of the new thing and gives me a frame of reference to move forward.  So that’s what I’m doing, and the potential is tantalizing.

Phase One

Phase one was pushed to GitHub this morning.  You can now run ScriptCS code inside of a PowerShell session:

PS > ipmo scriptcs
PS > invoke-scriptcs '"Hello PowerShell!"'
Hello PowerShell!

You can even pipe data to ScriptCS and consume it:

PS > 0..9 | invoke-scriptcs '(int)pscmdlet.Input[0] + 100'
100
101
102
103
104
105
106
107
108
109

And put data from ScriptCS onto the pipe:

PS > 0..9 | `
    invoke-scriptcs '(int)pscmdlet.Input[0] + 100' | `
   %{ "Output: $_" }
Output: 100
Output: 101
Output: 102
Output: 103
Output: 104
Output: 105
Output: 106
Output: 107
Output: 108
Output: 109

There’s still lots to do, but the possibilities are pretty amazing.  Ever wished you could use LINQ from PowerShell?  Now you can:

PS > invoke-scriptcs -input (0..9) -script 'from i in pscmdlet.Input where (int)i > 5 select i'
6
7
8
9

Phase 2

Phase 2 is pretty much the opposite of what I’ve done so far.  Phase two is a Script Pack for ScriptCS that allows you to run arbitrary PowerShell script in ScriptCS.  This is working now – the plan is to clean it up over the next week and make it public.  Stay tuned…