Skip to content

Instantly share code, notes, and snippets.

@jonathanmorley
Created April 7, 2016 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jonathanmorley/c71bc861c4625eb927d06279ac8ec39e to your computer and use it in GitHub Desktop.
Save jonathanmorley/c71bc861c4625eb927d06279ac8ec39e to your computer and use it in GitHub Desktop.
Powershell REPL for windows kitchen machines over WinRM
require 'highline/import'
require 'winrm'
endpoint = 'http://localhost:5985/wsman'
winrm = WinRM::WinRMWebService.new(endpoint, :negotiate, user: 'vagrant', pass: 'vagrant')
winrm.create_executor do |executor|
loop do
executor.run_powershell_script(ask "PS ...> ") do |stdout, stderr|
STDOUT.print stdout
STDERR.print stderr
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment