package
lightweight, functional, promise-based powershell wrapper
npm install windows-powershellGitHub-flavored package documentation.
Across all versions.
Download trend unavailable.
Runtime metadata.
Tagged topics.
:zap: Lightweight, functional, promise-based powershell wrapper
npm install windows-powershell#pipe()LastErrorCode -> lastErrorCode)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.
import { shell, pipe, toJson } from 'windows-powershell'
function process (io) {
const { json, stdout, stderr } = io
// json -> { name: 'regedit.exe' }
// stdout -> raw output from the cli
}
const cmd = pipe('get-itemproperty c:\\windows\\regedit.exe', 'select name')
shell(toJson(cmd)).then(process)native powershell$a = new-object PSObject; $a | add-member name test; $a | add-member version 0.0.1; $awindows-powershellshell(create({ name: 'test', version: '0.0.1' })).then(logStdout)outputname version
---- -------
test 0.0.1 Composing commands allows as to create intermediate values.
native powershell$a = 1; $a = 2; echo $a + $b;windows-powershellshell(compose('$a = 1', '$a = 2', 'echo $a + $b')).then(logStdout)output3native powershellget-wmiobject Win32_LogicalDisk | select namewindows-powershellconst cmd = pipe(
'get-wmiobject Win32_LogicalDisk',
'select name'
)
shell(cmd).then(logStdout)outputname
----
C:
D:
H:npm testEstimated unpacked size across 13 packages.
56.7 kB
Includes dependencies.
3 direct · 1 outdated