winrm 1.3.5 → 1.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md CHANGED
@@ -1,148 +1,148 @@
1
- # Windows Remote Management (WinRM) for Ruby
2
- [![Build Status](https://travis-ci.org/WinRb/WinRM.svg?branch=master)](https://travis-ci.org/WinRb/WinRM)
3
- [![Gem Version](https://badge.fury.io/rb/winrm.svg)](http://badge.fury.io/rb/winrm)
4
-
5
- This is a SOAP library that uses the functionality in Windows Remote
6
- Management(WinRM) to call native object in Windows. This includes, but is
7
- not limitted to, running batch scripts, powershell scripts and fetching WMI
8
- variables. For more information on WinRM, please visit Microsoft's WinRM
9
- site: http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx
10
-
11
- ## Supported WinRM Versions
12
- WinRM 1.1 is supported, however 2.0 and higher is recommended. [See MSDN](http://technet.microsoft.com/en-us/library/ff520073(v=ws.10).aspx) for information about WinRM versions and supported operating systems.
13
-
14
- ## Install
15
- `gem install -r winrm` then on the server `winrm quickconfig` as admin
16
-
17
- ## Example
18
- ```ruby
19
- require 'winrm'
20
- endpoint = 'http://mywinrmhost:5985/wsman'
21
- krb5_realm = 'EXAMPLE.COM'
22
- winrm = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => krb5_realm)
23
- winrm.cmd('ipconfig /all') do |stdout, stderr|
24
- STDOUT.print stdout
25
- STDERR.print stderr
26
- end
27
- ```
28
-
29
- There are various connection types you can specify upon initialization:
30
-
31
- It is recommended that you <code>:disable_sspi => true</code> if you are using the plaintext or ssl transport.
32
-
33
- #### Plaintext
34
- ```ruby
35
- WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :disable_sspi => true)
36
-
37
- ## Same but force basic authentication:
38
- WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :basic_auth_only => true)
39
- ```
40
-
41
- #### SSL
42
- ```ruby
43
- WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :disable_sspi => true)
44
-
45
- # Specifying CA path
46
- WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :ca_trust_path => '/etc/ssl/certs/cert.pem', :basic_auth_only => true)
47
-
48
- # Same but force basic authentication:
49
- WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true)
50
-
51
- # Basic auth over SSL w/self signed cert
52
- # Enabling no_ssl_peer_verification is not recommended. HTTPS connections are still encrypted,
53
- # but the WinRM gem is not able to detect forged replies or man in the middle attacks.
54
- WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :no_ssl_peer_verification => true)
55
- ```
56
-
57
- ##### Create a self signed cert for WinRM
58
- You may want to create a self signed certificate for servicing https WinRM connections. First you must install makecert.exe from the Windows SDK, then you can use the following PowerShell script to create a cert and enable the WinRM HTTPS listener.
59
-
60
- ```powershell
61
- $hostname = $Env:ComputerName
62
-
63
- C:\"Program Files"\"Microsoft SDKs"\Windows\v7.1\Bin\makecert.exe -r -pe -n "CN=$hostname,O=vagrant" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 "$hostname.cer"
64
-
65
- $thumbprint = (& ls cert:LocalMachine/my).Thumbprint
66
- $cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$hostname`";CertificateThumbprint=`"$thumbprint`"}'"
67
- iex $cmd
68
- ```
69
-
70
- #### Kerberos
71
- ```ruby
72
- WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => 'MYREALM.COM')
73
- ```
74
-
75
- ## Troubleshooting
76
- You may have some errors like ```WinRM::WinRMAuthorizationError```.
77
- You can run the following commands on the server to try to solve the problem:
78
- ```
79
- winrm set winrm/config/client/auth @{Basic="true"}
80
- winrm set winrm/config/service/auth @{Basic="true"}
81
- winrm set winrm/config/service @{AllowUnencrypted="true"}
82
- ```
83
- You can read more about that on issue [#29](https://github.com/WinRb/WinRM/issues/29)
84
-
85
-
86
- ## Current features
87
-
88
- 1. GSSAPI support: This is the default way that Windows authenticates and
89
- secures WinRM messages. In order for this to work the computer you are
90
- connecting to must be a part of an Active Directory domain and you must
91
- have local credentials via kinit. GSSAPI support is dependent on the
92
- gssapi gem which only supports the MIT Kerberos libraries at this time.
93
-
94
- If you are using this method there is no longer a need to change the
95
- WinRM service authentication settings. You can simply do a
96
- 'winrm quickconfig' on your server or enable WinRM via group policy and
97
- everything should be working.
98
-
99
- 2. Multi-Instance support: Moving away from Handsoap allows multiple
100
- instances to be created because the SOAP backend is no longer a Singleton
101
- type class.
102
-
103
- 3. 100% Ruby: Nokogiri while faster can present additional frustration for
104
- users above and beyond what is already required to get WinRM working.
105
- The goal of this gem is make using WinRM easy. In V2 we plan on making
106
- the parser swappable in case you really do need the performance.
107
-
108
- ## Contributing
109
-
110
- 1. Fork it.
111
- 2. Create a branch (git checkout -b my_feature_branch)
112
- 3. Run the unit and integration tests (bundle exec rake integration)
113
- 4. Commit your changes (git commit -am "Added a sweet feature")
114
- 5. Push to the branch (git push origin my_feature_branch)
115
- 6. Create a pull requst from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
116
-
117
- ### Running the tests
118
-
119
- We use Bundler to manage dependencies during development.
120
-
121
- ```
122
- $ bundle install
123
- ```
124
-
125
- Once you have the dependencies, you can run the unit tests with `rake`:
126
-
127
- ```
128
- $ bundle exec rake spec
129
- ```
130
-
131
- To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use a Vagrant Windows box.
132
-
133
- 1. Create a Windows VM with WinRM configured (see above).
134
- 2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
135
- 3. Ensure that the box you are running the test against has a default shell profile (check ~\Documents\WindowsPowerShell). If any of your shell profiles generate stdout or stderr output, the test validators may get thrown off.
136
- 4. Run `bundle exec rake integration`
137
-
138
- ## WinRM Author
139
- * Twitter: [@zentourist](https://twitter.com/zentourist)
140
- * BLOG: [http://distributed-frostbite.blogspot.com/](http://distributed-frostbite.blogspot.com/)
141
- * Add me in LinkedIn: [http://www.linkedin.com/in/danwanek](http://www.linkedin.com/in/danwanek)
142
- * Find me on irc.freenode.net in #ruby-lang (zenChild)
143
-
144
- ## Maintainers
145
- * Paul Morton (https://github.com/pmorton)
146
- * Shawn Neal (https://github.com/sneal)
147
-
148
- [Contributors](https://github.com/WinRb/WinRM/graphs/contributors)
1
+ # Windows Remote Management (WinRM) for Ruby
2
+ [![Build Status](https://travis-ci.org/WinRb/WinRM.svg?branch=master)](https://travis-ci.org/WinRb/WinRM)
3
+ [![Gem Version](https://badge.fury.io/rb/winrm.svg)](http://badge.fury.io/rb/winrm)
4
+
5
+ This is a SOAP library that uses the functionality in Windows Remote
6
+ Management(WinRM) to call native object in Windows. This includes, but is
7
+ not limitted to, running batch scripts, powershell scripts and fetching WMI
8
+ variables. For more information on WinRM, please visit Microsoft's WinRM
9
+ site: http://msdn.microsoft.com/en-us/library/aa384426(v=VS.85).aspx
10
+
11
+ ## Supported WinRM Versions
12
+ WinRM 1.1 is supported, however 2.0 and higher is recommended. [See MSDN](http://technet.microsoft.com/en-us/library/ff520073(v=ws.10).aspx) for information about WinRM versions and supported operating systems.
13
+
14
+ ## Install
15
+ `gem install -r winrm` then on the server `winrm quickconfig` as admin
16
+
17
+ ## Example
18
+ ```ruby
19
+ require 'winrm'
20
+ endpoint = 'http://mywinrmhost:5985/wsman'
21
+ krb5_realm = 'EXAMPLE.COM'
22
+ winrm = WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => krb5_realm)
23
+ winrm.cmd('ipconfig /all') do |stdout, stderr|
24
+ STDOUT.print stdout
25
+ STDERR.print stderr
26
+ end
27
+ ```
28
+
29
+ There are various connection types you can specify upon initialization:
30
+
31
+ It is recommended that you <code>:disable_sspi => true</code> if you are using the plaintext or ssl transport.
32
+
33
+ #### Plaintext
34
+ ```ruby
35
+ WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :disable_sspi => true)
36
+
37
+ ## Same but force basic authentication:
38
+ WinRM::WinRMWebService.new(endpoint, :plaintext, :user => myuser, :pass => mypass, :basic_auth_only => true)
39
+ ```
40
+
41
+ #### SSL
42
+ ```ruby
43
+ WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :disable_sspi => true)
44
+
45
+ # Specifying CA path
46
+ WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :ca_trust_path => '/etc/ssl/certs/cert.pem', :basic_auth_only => true)
47
+
48
+ # Same but force basic authentication:
49
+ WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true)
50
+
51
+ # Basic auth over SSL w/self signed cert
52
+ # Enabling no_ssl_peer_verification is not recommended. HTTPS connections are still encrypted,
53
+ # but the WinRM gem is not able to detect forged replies or man in the middle attacks.
54
+ WinRM::WinRMWebService.new(endpoint, :ssl, :user => myuser, :pass => mypass, :basic_auth_only => true, :no_ssl_peer_verification => true)
55
+ ```
56
+
57
+ ##### Create a self signed cert for WinRM
58
+ You may want to create a self signed certificate for servicing https WinRM connections. First you must install makecert.exe from the Windows SDK, then you can use the following PowerShell script to create a cert and enable the WinRM HTTPS listener.
59
+
60
+ ```powershell
61
+ $hostname = $Env:ComputerName
62
+
63
+ C:\"Program Files"\"Microsoft SDKs"\Windows\v7.1\Bin\makecert.exe -r -pe -n "CN=$hostname,O=vagrant" -eku 1.3.6.1.5.5.7.3.1 -ss my -sr localMachine -sky exchange -sp "Microsoft RSA SChannel Cryptographic Provider" -sy 12 "$hostname.cer"
64
+
65
+ $thumbprint = (& ls cert:LocalMachine/my).Thumbprint
66
+ $cmd = "winrm create winrm/config/Listener?Address=*+Transport=HTTPS '@{Hostname=`"$hostname`";CertificateThumbprint=`"$thumbprint`"}'"
67
+ iex $cmd
68
+ ```
69
+
70
+ #### Kerberos
71
+ ```ruby
72
+ WinRM::WinRMWebService.new(endpoint, :kerberos, :realm => 'MYREALM.COM')
73
+ ```
74
+
75
+ ## Troubleshooting
76
+ You may have some errors like ```WinRM::WinRMAuthorizationError```.
77
+ You can run the following commands on the server to try to solve the problem:
78
+ ```
79
+ winrm set winrm/config/client/auth @{Basic="true"}
80
+ winrm set winrm/config/service/auth @{Basic="true"}
81
+ winrm set winrm/config/service @{AllowUnencrypted="true"}
82
+ ```
83
+ You can read more about that on issue [#29](https://github.com/WinRb/WinRM/issues/29)
84
+
85
+
86
+ ## Current features
87
+
88
+ 1. GSSAPI support: This is the default way that Windows authenticates and
89
+ secures WinRM messages. In order for this to work the computer you are
90
+ connecting to must be a part of an Active Directory domain and you must
91
+ have local credentials via kinit. GSSAPI support is dependent on the
92
+ gssapi gem which only supports the MIT Kerberos libraries at this time.
93
+
94
+ If you are using this method there is no longer a need to change the
95
+ WinRM service authentication settings. You can simply do a
96
+ 'winrm quickconfig' on your server or enable WinRM via group policy and
97
+ everything should be working.
98
+
99
+ 2. Multi-Instance support: Moving away from Handsoap allows multiple
100
+ instances to be created because the SOAP backend is no longer a Singleton
101
+ type class.
102
+
103
+ 3. 100% Ruby: Nokogiri while faster can present additional frustration for
104
+ users above and beyond what is already required to get WinRM working.
105
+ The goal of this gem is make using WinRM easy. In V2 we plan on making
106
+ the parser swappable in case you really do need the performance.
107
+
108
+ ## Contributing
109
+
110
+ 1. Fork it.
111
+ 2. Create a branch (git checkout -b my_feature_branch)
112
+ 3. Run the unit and integration tests (bundle exec rake integration)
113
+ 4. Commit your changes (git commit -am "Added a sweet feature")
114
+ 5. Push to the branch (git push origin my_feature_branch)
115
+ 6. Create a pull requst from your branch into master (Please be sure to provide enough detail for us to cipher what this change is doing)
116
+
117
+ ### Running the tests
118
+
119
+ We use Bundler to manage dependencies during development.
120
+
121
+ ```
122
+ $ bundle install
123
+ ```
124
+
125
+ Once you have the dependencies, you can run the unit tests with `rake`:
126
+
127
+ ```
128
+ $ bundle exec rake spec
129
+ ```
130
+
131
+ To run the integration tests you will need a Windows box with the WinRM service properly configured. Its easiest to use a Vagrant Windows box.
132
+
133
+ 1. Create a Windows VM with WinRM configured (see above).
134
+ 2. Copy the config-example.yml to config.yml - edit this file with your WinRM connection details.
135
+ 3. Ensure that the box you are running the test against has a default shell profile (check ~\Documents\WindowsPowerShell). If any of your shell profiles generate stdout or stderr output, the test validators may get thrown off.
136
+ 4. Run `bundle exec rake integration`
137
+
138
+ ## WinRM Author
139
+ * Twitter: [@zentourist](https://twitter.com/zentourist)
140
+ * BLOG: [http://distributed-frostbite.blogspot.com/](http://distributed-frostbite.blogspot.com/)
141
+ * Add me in LinkedIn: [http://www.linkedin.com/in/danwanek](http://www.linkedin.com/in/danwanek)
142
+ * Find me on irc.freenode.net in #ruby-lang (zenChild)
143
+
144
+ ## Maintainers
145
+ * Paul Morton (https://github.com/pmorton)
146
+ * Shawn Neal (https://github.com/sneal)
147
+
148
+ [Contributors](https://github.com/WinRb/WinRM/graphs/contributors)
data/Rakefile CHANGED
@@ -1,28 +1,28 @@
1
- # encoding: UTF-8
2
- require 'rubygems'
3
- require 'bundler/setup'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
6
- require 'bundler/gem_tasks'
7
-
8
- # Change to the directory of this file.
9
- Dir.chdir(File.expand_path('../', __FILE__))
10
-
11
- RSpec::Core::RakeTask.new(:spec) do |task|
12
- task.pattern = 'spec/*_spec.rb'
13
- task.rspec_opts = ['--color', '-f documentation']
14
- task.rspec_opts << '-tunit'
15
- end
16
-
17
- # Run the integration test suite
18
- RSpec::Core::RakeTask.new(:integration) do |task|
19
- task.pattern = 'spec/*_spec.rb'
20
- task.rspec_opts = ['--color', '-f documentation']
21
- task.rspec_opts << '-tintegration'
22
- end
23
-
24
- RuboCop::RakeTask.new
25
-
26
- task default: [:spec, :rubocop]
27
-
28
- task all: [:default, :integration]
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'bundler/setup'
4
+ require 'rspec/core/rake_task'
5
+ require 'rubocop/rake_task'
6
+ require 'bundler/gem_tasks'
7
+
8
+ # Change to the directory of this file.
9
+ Dir.chdir(File.expand_path('../', __FILE__))
10
+
11
+ RSpec::Core::RakeTask.new(:spec) do |task|
12
+ task.pattern = 'spec/*_spec.rb'
13
+ task.rspec_opts = ['--color', '-f documentation']
14
+ task.rspec_opts << '-tunit'
15
+ end
16
+
17
+ # Run the integration test suite
18
+ RSpec::Core::RakeTask.new(:integration) do |task|
19
+ task.pattern = 'spec/*_spec.rb'
20
+ task.rspec_opts = ['--color', '-f documentation']
21
+ task.rspec_opts << '-tintegration'
22
+ end
23
+
24
+ RuboCop::RakeTask.new
25
+
26
+ task default: [:spec, :rubocop]
27
+
28
+ task all: [:default, :integration]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.5
1
+ 1.3.6
@@ -1,9 +1,9 @@
1
- # encoding: UTF-8
2
- # -*- mode: ruby -*-
3
- # vi: set ft=ruby :
4
-
5
- VAGRANTFILE_API_VERSION = '2'
6
-
7
- Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
- config.vm.box = 'mwrock/Windows2012R2'
9
- end
1
+ # encoding: UTF-8
2
+ # -*- mode: ruby -*-
3
+ # vi: set ft=ruby :
4
+
5
+ VAGRANTFILE_API_VERSION = '2'
6
+
7
+ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
8
+ config.vm.box = 'mwrock/Windows2012R2'
9
+ end
data/bin/rwinrm CHANGED
@@ -1,97 +1,97 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- # Copyright 2014 Shawn Neal <sneal@sneal.net>
5
- #
6
- # Licensed under the Apache License, Version 2.0 (the "License");
7
- # you may not use this file except in compliance with the License.
8
- # You may obtain a copy of the License at
9
- #
10
- # http://www.apache.org/licenses/LICENSE-2.0
11
- #
12
- # Unless required by applicable law or agreed to in writing, software
13
- # distributed under the License is distributed on an "AS IS" BASIS,
14
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- # See the License for the specific language governing permissions and
16
- # limitations under the License.
17
-
18
- # rubocop:disable all
19
-
20
- $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
21
-
22
- require 'readline'
23
- require 'io/console'
24
- require 'winrm'
25
-
26
- def help_msg
27
- puts 'Usage: rwinrm user@host'
28
- puts ''
29
- end
30
-
31
- def parse_options
32
- options = {}
33
- fail 'Missing required options' unless ARGV.length == 1
34
-
35
- m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?/i.match(ARGV[0])
36
- fail "#{ARGV[0]} is an invalid host" unless m
37
- options[:user] = m[:user]
38
- options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
39
-
40
- # Get the password
41
- print 'Password: '
42
- options[:pass] = STDIN.noecho(&:gets).chomp
43
- puts
44
-
45
- # Set some defaults required by WinRM WS
46
- options[:auth_type] = :plaintext
47
- options[:basic_auth_only] = true
48
-
49
- options
50
- rescue StandardError => e
51
- puts e.message
52
- help_msg
53
- exit 1
54
- end
55
-
56
- def repl(options)
57
- client = WinRM::WinRMWebService.new(
58
- options[:endpoint],
59
- options[:auth_type].to_sym,
60
- options)
61
-
62
- client.set_timeout(3600)
63
- shell_id = client.open_shell
64
- command_id = client.run_command(shell_id, 'cmd', "/K prompt [#{ARGV[0]}]$P$G")
65
-
66
- read_thread = Thread.new do
67
- client.get_command_output(shell_id, command_id) do |stdout, stderr|
68
- STDOUT.write stdout
69
- STDERR.write stderr
70
- end
71
- end
72
- read_thread.abort_on_exception = true
73
-
74
- while (buf = Readline.readline('', true))
75
- if buf =~ /^exit/
76
- read_thread.exit
77
- client.cleanup_command(shell_id, command_id)
78
- client.close_shell(shell_id)
79
- exit 0
80
- else
81
- client.write_stdin(shell_id, command_id, "#{buf}\r\n")
82
- end
83
- end
84
- rescue Interrupt
85
- puts 'exiting'
86
- # ctrl-c
87
- rescue WinRM::WinRMAuthorizationError
88
- puts 'Authentication failed, bad user name or password'
89
- exit 1
90
- rescue StandardError => e
91
- puts e.message
92
- exit 1
93
- end
94
-
95
- repl(parse_options)
96
-
97
- # rubocop:enable all
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # Copyright 2014 Shawn Neal <sneal@sneal.net>
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ # rubocop:disable all
19
+
20
+ $LOAD_PATH.push File.expand_path('../../lib', __FILE__)
21
+
22
+ require 'readline'
23
+ require 'io/console'
24
+ require 'winrm'
25
+
26
+ def help_msg
27
+ puts 'Usage: rwinrm user@host'
28
+ puts ''
29
+ end
30
+
31
+ def parse_options
32
+ options = {}
33
+ fail 'Missing required options' unless ARGV.length == 1
34
+
35
+ m = /^(?<user>[a-z0-9\.\!\$ _-]+)@{1}(?<host>[a-z0-9\.\-]+)(?<port>:[0-9]+)?/i.match(ARGV[0])
36
+ fail "#{ARGV[0]} is an invalid host" unless m
37
+ options[:user] = m[:user]
38
+ options[:endpoint] = "http://#{m[:host]}#{m[:port] || ':5985'}/wsman"
39
+
40
+ # Get the password
41
+ print 'Password: '
42
+ options[:pass] = STDIN.noecho(&:gets).chomp
43
+ puts
44
+
45
+ # Set some defaults required by WinRM WS
46
+ options[:auth_type] = :plaintext
47
+ options[:basic_auth_only] = true
48
+
49
+ options
50
+ rescue StandardError => e
51
+ puts e.message
52
+ help_msg
53
+ exit 1
54
+ end
55
+
56
+ def repl(options)
57
+ client = WinRM::WinRMWebService.new(
58
+ options[:endpoint],
59
+ options[:auth_type].to_sym,
60
+ options)
61
+
62
+ client.set_timeout(3600)
63
+ shell_id = client.open_shell
64
+ command_id = client.run_command(shell_id, 'cmd', "/K prompt [#{ARGV[0]}]$P$G")
65
+
66
+ read_thread = Thread.new do
67
+ client.get_command_output(shell_id, command_id) do |stdout, stderr|
68
+ STDOUT.write stdout
69
+ STDERR.write stderr
70
+ end
71
+ end
72
+ read_thread.abort_on_exception = true
73
+
74
+ while (buf = Readline.readline('', true))
75
+ if buf =~ /^exit/
76
+ read_thread.exit
77
+ client.cleanup_command(shell_id, command_id)
78
+ client.close_shell(shell_id)
79
+ exit 0
80
+ else
81
+ client.write_stdin(shell_id, command_id, "#{buf}\r\n")
82
+ end
83
+ end
84
+ rescue Interrupt
85
+ puts 'exiting'
86
+ # ctrl-c
87
+ rescue WinRM::WinRMAuthorizationError
88
+ puts 'Authentication failed, bad user name or password'
89
+ exit 1
90
+ rescue StandardError => e
91
+ puts e.message
92
+ exit 1
93
+ end
94
+
95
+ repl(parse_options)
96
+
97
+ # rubocop:enable all