# nodejs-winrm

> Make WinRM service calls from NodeJS

Latest version **1.1.3** (published 2020-09-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install nodejs-winrm
pnpm add nodejs-winrm
yarn add nodejs-winrm
bun add nodejs-winrm
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2020-09-17 |
| First published | 2018-12-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 17.6 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 11 |
| Author | Shone Jacob |
| Maintainers | shoneslab |
| Keywords | winrm |

## Links

- npm: https://www.npmjs.com/package/nodejs-winrm
- Repository: https://github.com/shoneslab/nodejs-winrm
- Homepage: https://github.com/shoneslab/nodejs-winrm#readme
- Issues: https://github.com/shoneslab/nodejs-winrm/issues
- npm.io page: https://npm.io/package/nodejs-winrm

## Dependencies (3)

- [uuid](https://npm.io/package/uuid.md) ^3.3.2
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.19
- [js2xmlparser](https://npm.io/package/js2xmlparser.md) ^3.0.0

## Recent versions

- 1.1.3 (latest) — 2020-09-17
- 1.1.2 — 2018-12-18
- 1.1.1 — 2018-12-18
- 1.1.0 — 2018-12-12
- 1.0.4 — 2018-12-11
- 1.0.3 — 2018-12-10
- 1.0.2 — 2018-12-10
- 1.0.1 — 2018-12-10
- 1.0.0 — 2018-12-09

## README

# nodejs-winrm

[![npm version](https://badge.fury.io/js/nodejs-winrm.svg)](https://badge.fury.io/js/nodejs-winrm)
[![Build Status](https://travis-ci.org/shoneslab/nodejs-winrm.svg?branch=master)](https://travis-ci.org/shoneslab/nodejs-winrm)
[![Build Status](https://dev.azure.com/SHONEJACOB/SHONEJACOB/_apis/build/status/shoneslab.nodejs-winrm?branchName=master)](https://dev.azure.com/SHONEJACOB/SHONEJACOB/_build/latest?definitionId=1?branchName=master)

nodejs-winrm is a NodeJS client to access WinRM (Windows Remote Management) SOAP web service. It allows to execute commands on target windows machines.
Please visit [Microsoft's WinRM site](http://msdn.microsoft.com/en-us/library/aa384426.aspx) for WINRM details.

## Supported NodeJS Versions

Tested on NodeJS Version > 8.11

## Supported WinRM Versions

As of now Winrm Version 3 is tested.

```
> winrm id

IdentifyResponse
    ProtocolVersion = http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
    ProductVendor = Microsoft Corporation
    ProductVersion = OS: 10.0.xxxx SP: 0.0 Stack: 3.0
```

## Install

On the remote host, a PowerShell prompt, using the __Run as Administrator__ option and paste in the following lines:

```
> winrm quickconfig
y
> winrm set winrm/config/service/Auth '@{Basic="true"}'
> winrm set winrm/config/service '@{AllowUnencrypted="true"}'
> winrm set winrm/config/winrs '@{MaxMemoryPerShellMB="1024"}'
```
On the client side where NodeJS is installed

`npm install nodejs-winrm`

## Examples

### Run a Single Command 
```
var winrm = require('nodejs-winrm');
winrm.runCommand('mkdir D:\\winrmtest001', '10.xxx.xxx.xxx', 'username', 'password', 5985);
winrm.runCommand('ipconfig /all', '10.xxx.xxx.xxx', 'username', 'password', 5985);
```
### Run multiple Commands (Advanced)
```
var winrm = require('nodejs-winrm');

var userName = 'userName';
var password = 'password';
var _host = '10.xxx.xxx.xxx';
var _port = 5985;

var auth = 'Basic ' + Buffer.from(userName + ":" + password, 'utf8').toString('base64');
var params = {
    host: _host,
    port: _port,
    path: '/wsman'
};
params['auth'] = auth;

//Get the Shell ID
params['shellId']= await winrm.shell.doCreateShell(params);

// Execute Command1
params['command'] = 'ipconfig /all';
params['commandId'] = await winrm.command.doExecuteCommand(params);
var result1= await winrm.command.doReceiveOutput(params);

// Execute Command2
params['command'] = 'mkdir D:\\winrmtest001';
params['commandId'] = await winrm.command.doExecuteCommand(params);
var result2= await winrm.command.doReceiveOutput(params);

// Close the Shell
await winrm.shell.doDeleteShell(params);

```


## Testing

`npm test`

## Maintainers
* Shone Jacob (https://github.com/shoneslab)

## Credits
* https://github.com/jacobludriks/winrmjs

---
_Source: https://npm.io/package/nodejs-winrm · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
