Skip to content
Abderrahmene Merzoug edited this page Sep 15, 2023 · 2 revisions

PowerJS

Unleash the Power of PowerShell in Your JavaScript

PowerJS is a versatile JavaScript library that seamlessly integrates PowerShell capabilities into your applications. Execute PowerShell commands, interact with DLLs, and create powerful applications effortlessly. Empower your JavaScript projects with the magic of PowerShell, simplifying automation and enhancing functionality.

In this page we will every step to a successful and working installation of powerjs.

Installation

Getting started with PowerJS is quick and straightforward. You can install it via npm:

npm install obaydmerz/powerjs

Ensure you have PowerShell

PowerShell can be running behind some names like: pwsh and powershell. So try to figure the one that you will use with this library.

To check if a powershell installation is working, type:

pwsh -Command $PSVersionTable

Feel free to replace pwsh with the one you want.

What if you want to use different names than pwsh and powershell?

Using a custom installation with a different name and/or installation path:

First you have to check the validity of the installation using the command above, then grab that path/name and remember it. You can put it into env variables and use it's name with/without file extension.

Or you should include it's full ( absolute ) path.

Then, add it in:

import { PowerJS } from 'powerjs';

const myWorkingInstance = new PowerJS({
   additionalShellNames: ["c:/path/to/working/shell", "myPowershell.exe", ""] // <- Here
});

Q/A

Q: Do i need to build any files and use node-gyp? A: PowerJS doesn't include any native files that you can worry about 😅

Q: Can PowerJS be included in packaged apps? ( using nexe and pkg ) A: Because the library is written in 100% pure javascript and it doesn't require any additional dependencies, it should be able to be used in any way.

If you have any issues with the installation, feel free to read and/or open issues in github issue tracker ⚙️