DEPRECATED: EventMachine based, asynchronous parallel client for Windows Remote Management (WinRM).
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2015-07-23 11:36:51 -05:00
lib Release 0.7.0 2015-07-23 11:32:29 -05:00
.gitignore initial commit 2011-03-01 14:30:30 -05:00
CHANGELOG.md Update CHANGELOG for 0.7.0 2015-07-23 11:34:44 -05:00
em-winrm.gemspec Merge pull request #20 from mwrock/master 2015-03-10 13:13:13 -04:00
Gemfile Modified source to be https 2013-06-19 17:46:27 -07:00
LICENSE initial commit 2011-03-01 14:30:30 -05:00
Rakefile initial commit 2011-03-01 14:30:30 -05:00
README.rdoc Deprecation notice 2015-01-24 23:38:27 -08:00

= EM-WinRM

An EventMachine client for Windows Remote Management (WinRM). This allows you to
invoke commands on Windows machines from any machine that can run Ruby.  This
client leverages the EventMachine reactor to run the same command across multiple
machines in parallel (think net-ssh-multi).

WinRM allows you to call native objects in Windows.  This includes, but is not
limited to, running batch scripts, powershell scripts and fetching WMI variables.
For more information on WinRM, please visit
{Microsoft's WinRM site}[http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx].

= Deprecation Notice

The functionality provided by this library has been merged into {knife-windows}[https://github.com/chef/knife-windows].
Following the release of knife-windows v1.0.0, this library will no longer be used and thus no longer be maintained.

= Example Usage

    servers = {
      'ec2-75-xxx-xxx-127.compute-1.amazonaws.com' => {:port => 80, :user => 'Administrator', :password => 'super_secret_passowrd'},
      'ec2-50-xxx-xxx-141.compute-1.amazonaws.com' => {:port => 80, :user => 'Administrator', :password => 'super_secret_passowrd'},
      'ec2-75-xxx-xxx-192.compute-1.amazonaws.com' => {:port => 80, :user => 'Administrator', :password => 'super_secret_passowrd'}
    }

    def h
      @highline ||= HighLine.new
    end

    def print_data(host, data, color = :cyan)
      if data =~ /\n/
          data.split(/\n/).each { |d| print_data(host, d, color) }
      else
        puts "#{h.color(host, color)} #{data.chomp}"
      end
    end

    # create a session
    session = EventMachine::WinRM::Session.new(:log_level => :info)

    # add some servers
    servers.each do |host,options|
      session.use(host,options)
    end

    # create some callbacks
    session.on_output do |host, data|
      print_data(host, data)
    end
    session.on_error do |host, err|
      print_data(host, data, :red)
    end
    session.on_finish do |host|
      host = host == :done ? 'All Servers' : host
      print_data(host, 'done.')
    end

    # run a command
    session.relay_command('dir')

Gives the following output:

    ec2-75-xxx-xxx-192.compute-1.amazonaws.com  Volume in drive C has no label.
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com  Volume Serial Number is 9415-4101
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com  Directory of C:\Users\Administrator
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          .
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          ..
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Contacts
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Desktop
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Documents
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Downloads
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Favorites
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Links
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Music
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Pictures
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Saved Games
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Searches
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com 03/01/2011  03:30 AM    <DIR>          Videos
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com                0 File(s)              0 bytes
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com               13 Dir(s)  21,553,827,840 bytes free
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com  Volume in drive C has no label.
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com  Volume Serial Number is 9415-4101
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com  Directory of C:\Users\Administrator
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          .
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          ..
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Contacts
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Desktop
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Documents
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Downloads
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Favorites
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Links
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Music
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Pictures
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Saved Games
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Searches
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com 02/28/2011  06:13 PM    <DIR>          Videos
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com                0 File(s)              0 bytes
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com               13 Dir(s)  21,535,481,856 bytes free
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com  Volume in drive C has no label.
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com  Volume Serial Number is 9415-4101
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com  Directory of C:\Users\Administrator
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          .
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          ..
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Contacts
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Desktop
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Documents
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Downloads
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Favorites
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Links
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Music
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Pictures
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Saved Games
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Searches
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com 03/01/2011  01:17 AM    <DIR>          Videos
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com                0 File(s)              0 bytes
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com               13 Dir(s)  21,555,576,832 bytes free
    ec2-75-xxx-xxx-192.compute-1.amazonaws.com done.
    ec2-75-xxx-xxx-127.compute-1.amazonaws.com done.
    ec2-50-xxx-xxx-141.compute-1.amazonaws.com done.
    All Servers done.

= Credit

Thanks to {Dan Wanek}[http://github.com/zenchild] who wrote the
{WinRM Ruby client gem}[https://github.com/WinRb/WinRM] that is used heavily
by this gem.

Also big thanks to {Paul Morton}[https://github.com/pmorton] and
{Chris McClimans}[https://github.com/hh] (aka Hippie Hacker) for lots of real
world testing and features!

= Contact

* Twitter: @schisamo
* IRC: schisamo
* Email: schisamo@opscode.com

* Github: https://github.com/opscode/em-winrm
* Tickets: http://tickets.opscode.com # knife-windows project

= License

Author:: Seth Chisamore (<schisamo@opscode.com>)
Copyright:: Copyright (c) 2011 Seth Chisamore
License:: Apache License, Version 2.0

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.