Last active
October 27, 2015 17:46
-
-
Save carpnick/9c2a4b2292287172cf18 to your computer and use it in GitHub Desktop.
This file contains 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
require 'winrm' | |
require 'winrm-s' | |
@host="localhost" | |
@port="5985" | |
url = "#{@host}:#{@port}/wsman" | |
scheme="http" | |
@endpoint = "#{scheme}://#{url}" | |
opts = Hash.new | |
opts = {:user => "Administrator", :pass => "MyCoolPassword", :basic_auth_only => true, :disable_sspi => true, :no_ssl_peer_verification => true} | |
@winrm_session = WinRM::WinRMWebService.new(@endpoint,:plaintext,opts) | |
remote_id = @winrm_session.open_shell | |
command_id = @winrm_session.run_command(remote_id," exit 100" ) | |
#command_id = @winrm_session.run_command(remote_id,"echo hello && exit 100" ) | |
@winrm_session.get_command_output(remote_id, command_id) do |out,error| | |
puts out if out | |
puts error if error | |
end | |
@winrm_session.cleanup_command(remote_id, command_id) | |
@winrm_session.close_shell(remote_id) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment