windows-powershell
⚡️ Lightweight, functional, promise-based powershell wrapper
Installation
npm install windows-powershell
Features
- Promise API
- Composable API via
#pipe()
- Converts powershell like objects to json
- Converts pascal case keys to camel case (
LastErrorCode
->lastErrorCode
)
Example
In this example we get the name of regedit.exe
. As you can see we don't need to parse the output since it has already been converted to json.
{ const json stdout stderr = io // json -> { name: 'regedit.exe' } // stdout -> raw output from the cli} const cmd =
Creating objects
native powershell
$a = new-object PSObject; $a | add-member name test; $a | add-member version 0.0.1; $a
windows-powershell
output
name version
---- -------
test 0.0.1
Composing
Composing commands allows as to create intermediate values.
native powershell
$a = 1; $a = 2; echo $a + $b;
windows-powershell
output
3
Piping
native powershell
get-wmiobject Win32_LogicalDisk | select name
windows-powershell
const cmd =
output
name
----
C:
D:
H:
Tests
npm test