Home

Awesome

PowerShell.JS - JavaScript hosted inside PowerShell.

This Project will Host MS's Chakra Javascript Engine inside of PowerShell, providing Cmdlets to execute arbitary Javascript, Javascript Functions from within PowerShell Now Supporting TypeScript 1.0

##Goals

##MidTerm Goals

##Non-Goals

##Possible Future Scope

#Examples

 ipmo PowerChakra -Force
 
 #invoke a simple expression
 invoke-js "5+5"
 
 New-JSSession -Name test
 #invoke an expression, in a session, and DON'T RETURN RESULTS
 Invoke-JS -Name test -Script "var x = 5; function add(y){return y+y}" -NoResults
 #reuse the session, running a function previously applied AND return results.
 Invoke-JS -Name test -Script "add(x,10)"

 #create a nested PS object
 invoke-JS -Name test -Script "var ourobj = {name : 'PowerChakra', numbers : [1,2,3] , something: { x:1}  }" -NoResults
 #get object as JSON, then convert to PS object 
 $objectasJSON = invoke-JS -Name test -Script "JSON.stringify(ourobj)"
 $objectasJSON 
 $objectasPSobj = ConvertFrom-Json $objectasJSON
 $objectasPSobj | fl

A TypeScript Example

ipmo PowerShellJS -Force
$null = New-JSSession -Name test
Invoke-TypeScript -name test -script "1+1"
Invoke-TypeScript -name test -script "var adder = x => x * x" -NoResults
Invoke-JS -name test -Script "adder(5)"

#Installation Copy PSModule/PowerShellJS to your PowerShellModules folder, then load with Import-Module

###Random Notes SessionID and Name Call backs JS exceptions.

License

(C) 2013-2014 ShellTools LLC. Released under Microsoft Public License (Ms-PL)

The .Net Javascript Wrapper is derived from [MSieJavaScriptEngine] (http://github.com/Taritsyn/MsieJavaScriptEngine) Microsoft Public License (Ms-PL)

Credits