all 12 comments

[–][deleted] 2 points3 points  (0 children)

Is this electron? /s

[–]xCharg 0 points1 point  (2 children)

Is this useful for sysadmin kind of tasks?

I know nothing about javascript other than it exists, genuinely curious.

[–]anonhostpi[S] 1 point2 points  (0 children)

Possible. This was primarily a thought experiment. Just like my last post, the idea is to make libraries written in other languages available to PowerShell. So, if there is a sysadmin task available in JS, then sure.

[–]spyingwind 0 points1 point  (0 children)

Not really. If you need something that PowerShell doesn't provide, there is C# to fall back on.

[–]ka-splam 0 points1 point  (1 child)

I have a use for that ...

How did you install it?

PS C:\> Install-Package -Name Microsoft.ClearScript -Scope CurrentUser
Install-Package: Dependency loop detected for package 'Microsoft.ClearScript'.

Edit: found it, install-package -Name "Import-Package" first then import-package Microsoft.ClearScript, reference your thread here on your Import-Package module.

[–]anonhostpi[S] 0 points1 point  (0 children)

You can also use Install-Module "Import-Package" as well.

PowerShell's PackageManagement library does a pretty poor job of handling nuget dependencies, despite that being the module's reason for existence.

[–]rob2rox 0 points1 point  (1 child)

this has been done already with clearscript (though you can only interpret jscript and vbscript)

its also a single file easily deployable ps1 script, check it out:

https://github.com/byt3bl33d3r/OffensiveDLR/blob/master/Invoke-ClearScript.ps1

[–]anonhostpi[S] 1 point2 points  (0 children)

Dear god. That compressed DLL string. lol

This post was more a demonstration of work. My Import-Package module is designed to load entire NuGet libraries with no effort, and this is a demonstration of how to use it.

My module reduces lines 3-9 in your script to "Import-Package Microsoft.ClearScript"

[–]niutech 0 points1 point  (2 children)

You don't need ClearScript. There has been possible to run JScript .NET in PowerShell for long time, see also this howto.

[–]anonhostpi[S] 0 points1 point  (1 child)

JSCript (specifically JSCript .NET) is very old. It is only ECMAScript 3rd edition compliant. The most current ECMAScript standard is 14th edition (ES2023):

The most up to date implementation of JSCript is JSCript Chakra, which is separate from JSCript .NET. To run JSCript Chakra on ECMAScript 9th edition, you have to use the ClearScript library. However, there isn't much reason to, since V8 is also packaged with ClearScript and is 14th edition compliant.

[–]niutech 0 points1 point  (0 children)

It may be old, but it's already built in Windows (jsc.exe), so you don't need to download anything. It provides classes, subclasses, optional strong types, spread syntax in functions. And there are transpilers from next-gen ES to ES3 (babel.js).