Git Product home page Git Product logo

nodejs-winrm's Introduction

nodejs-winrm

npm version Build Status Build Status

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 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

Credits

nodejs-winrm's People

Contributors

azure-pipelines[bot] avatar shoneslab avatar tw00 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

nodejs-winrm's Issues

New Version Should Be Uploaded to NPM

Hi,

I see you have fixed the new Buffer issue 8 months ago. Unfortunately we could not use it because NPM package is still old. Can you create a new version with that change?

Minor error in advanced example

var auth = 'Basic' + Buffer.from(userName + ":" + password, 'utf8').toString('base64');

should be

var auth = 'Basic ' + Buffer.from(userName + ":" + password, 'utf8').toString('base64');

(note the space after "Basic")

Also it should probably be ipconfig instead of ipaddress ;-)

error Failed to process the request, status Code: 500 with an non admin WinRM Account

Hi there,

I'm encountering an issue where I'm unable to execute certain queries using a non-administrator remote account with these modules. While it works flawlessly with an account that has administrator privileges on the remote server, it doesn't work with a standard account. Interestingly, the non-administrator account functions properly; I can do WinRM from my Windows laptop using the non administrator account without any problems.
Someone know something about this problem ?

Thank !

Sincerely, Jérémy

Error: Failed to process the request, status Code

Error: Failed to process the request, status Code:
at ClientRequest.http.request (/home/jnm/node_modules/nodejs-winrm/src/http.js:22:24)

I have verified winrm setup with python code. winrm id returns:

C:\Windows\system32>winrm id
IdentifyResponse
ProtocolVersion = http://schemas.dmtf.org/wbem/wsman/1/wsman.xsd
ProductVendor = Microsoft Corporation
ProductVersion = OS: 10.0.14393 SP: 0.0 Stack: 3.0
SecurityProfiles
SecurityProfileName = http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/basic, http://schemas.dmtf.org/wbem/wsman/1/wsman/secprofile/http/spnego-kerberos

I think it is related to ntlm. Please help.

Kerberos authentication

The package works great for me when using it outside a Kerberos network.

Is there a way to authenticate using Kerberos?

Powershell commands not recognized

When executing powershell commands such as "Get-disk" Or "Copy-Item" throws an error as "Get-Disk not recognized as Internal or external command". Only executing the commands which are working in CMD.

winrm throws ECONRESET

var winrm = require('nodejs-winrm');

winrm.runCommand('mkdir D:\winrmtest001', '172.XX.208.XX', 'SCVMM\Administrator', 'XXinXXntXX', 5986);\

When trying to reach the above system, it takes so much time, giving ECONRESET error. The above system requires VPN to get connected.
Do let us know.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.