https://github.com/tomashubelbauer/node-wsb
Run a PowerShell script in Windows Sandbox from Node
https://github.com/tomashubelbauer/node-wsb
node wsb
Last synced: about 2 months ago
JSON representation
Run a PowerShell script in Windows Sandbox from Node
- Host: GitHub
- URL: https://github.com/tomashubelbauer/node-wsb
- Owner: TomasHubelbauer
- License: mit
- Created: 2020-11-14T18:35:18.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2022-04-28T08:50:55.000Z (about 4 years ago)
- Last Synced: 2025-06-01T16:40:07.715Z (about 1 year ago)
- Topics: node, wsb
- Language: JavaScript
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# Node Windows Sandbox
This library allows running PowerShell scripts in Windows Sandbox.
## Installation
`git submodule add https://github.com/tomashubelbauer/node-wsb`
To update:
```sh
cd node-wsb
git pull
cd ..
```
## Usage
```js
import wsb from './node-wsb/index.js';
console.log(await wsb('echo "Hello, World!"'));
```
The return value is an object:
- `stdout` (`string`): the output value in case of success
- `stderr` (`string`): the output value in case of failure
- `exitCode` (`number`): 0 for success, 1 for failure
- `transcript` (`object`):
- `startTime` (`string`): the transcript start instant in `yyyymmddhhmmss`
- `endTime` (`string`): the transcript end instant in `yyyymmddhhmmss`
- `meta` (`object`): an object made of transcript metadata key-value pairs
- `data`: (`string[]`) an array of lines written to the transcript
## Development
Run tests using `npm test`.
### To-Do
#### Address code to-do comments
Use [`todo`](https://github.com/tomashubelbauer/todo).
#### Finalize the `wait` argument logic - wait or bail based on its value
#### Add a "simulation" mode option which falls back to PowerShell direct
This would be used in the CI or when the user doesn't want to / can't enable WSB
on their machine.
#### Consider adding a Docker backend for non-Windows and CI environments maybe
Perhaps it should be a separate package though.
#### Look into using PowerShell remoting for communicating with the sandbox
I think we could find the sandbox' IP address and connect to it using PowerShell
remoting and run the commands that way. We might need to turn it on first.