Skip to content

Commit

Permalink
Support for WinRM 1.5+
Browse files Browse the repository at this point in the history
Allow winrm-elevated elevated runners to work alongside WinRM 1.5+
(now 1.7) Executors.

Only upload the wrapper shell winrm-elevated-shell.ps1 once per connection.
No need to do so on every command request.

Note that a TODO would be to more fully integrate the "elevated runner" with the
"command-executor".
  • Loading branch information
jerryk55 committed Feb 25, 2016
1 parent 2be6fa9 commit 349a443
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions lib/winrm-elevated/runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ def initialize(winrm_service)
@winrm_service = winrm_service
@winrm_file_manager = WinRM::FS::FileManager.new(winrm_service)
@elevated_shell_path = 'c:/windows/temp/winrm-elevated-shell.ps1'
@uploaded = nil
end

# Run a command or PowerShell script elevated without any of the
Expand All @@ -49,12 +50,14 @@ def powershell_elevated(script, username, password, &block)
private

def upload_elevated_shell_wrapper_script
return if @uploaded
file = Tempfile.new(['winrm-elevated-shell', 'ps1'])
begin
file.write(elevated_shell_script_content)
file.fsync
file.close
@winrm_file_manager.upload(file.path, @elevated_shell_path)
@uploaded = true
ensure
file.close
file.unlink
Expand Down
4 changes: 2 additions & 2 deletions winrm-elevated.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ Gem::Specification.new do |s|
s.extra_rdoc_files = %w(README.md LICENSE)

s.required_ruby_version = '>= 1.9.0'
s.add_runtime_dependency 'winrm', '~> 1.3'
s.add_runtime_dependency 'winrm-fs', '~> 0.2.2'
s.add_runtime_dependency 'winrm', '~> 1.7'
s.add_runtime_dependency 'winrm-fs', '~> 0.3.0'
s.add_development_dependency 'rspec', '~> 3.2'
s.add_development_dependency 'rake', '~> 10.3'
s.add_development_dependency 'rubocop', '~> 0.28'
Expand Down

0 comments on commit 349a443

Please sign in to comment.