Created
January 12, 2014 05:34
-
-
Save benjamine/8381365 to your computer and use it in GitHub Desktop.
simplistic WinRM CLI ruby script for Vagrant Windows guest machines ( https://github.com/WinRb/vagrant-windows )
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # requires: | |
| # gem instal -r winrm | |
| # gem install active_support | |
| command = ARGV.join(' ') | |
| if not command | |
| raise "no command specified, usage: winrm <windows command>" | |
| end | |
| require 'active_support/core_ext/kernel/reporting' | |
| # Silencing warnings because not all versions of GSSAPI support all of the GSSAPI methods | |
| # the gssapi gem attempts to attach to and these warnings are dumped to STDERR. | |
| silence_warnings do | |
| # Requiring winrm before all other gems because of https://github.com/WinRb/WinRM/issues/39 | |
| require 'winrm' | |
| end | |
| endpoint = 'http://localhost:5985/wsman' | |
| usr = 'vagrant' | |
| pwd = 'vagrant' | |
| winrm = WinRM::WinRMWebService.new(endpoint, :plaintext, :user => usr, :pass => pwd, :basic_auth_only => true, :disable_sspi => true) | |
| winrm.cmd(command) do |stdout, stderr| | |
| STDOUT.print stdout | |
| STDERR.print stderr | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment