Using JScript in powershell

This may be a good starting point

PowerShell ABC's - J is for JavaScript (by Joe Pruitt)

Here is a code snippet from the above article:

function Create-ScriptEngine()
{
  param([string]$language = $null, [string]$code = $null);
  if ( $language )
  {
    $sc = New-Object -ComObject ScriptControl;
    $sc.Language = $language;
    if ( $code )
    {
      $sc.AddCode($code);
    }
    $sc.CodeObject;
  }
}
PS> $jscode = @"
function jslen(s)
{
  return s.length;
}
"@
PS> $js = Create-ScriptEngine "JScript" $jscode;
PS> $str = "abcd";
PS> $js.jslen($str);
4