Created
March 22, 2013 18:11
-
-
Save turboladen/5223483 to your computer and use it in GitHub Desktop.
winrm running against my Vagrant-installed Win2k8
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 'kconv' | |
endpoint = 'http://192.168.33.10:5985/wsman' | |
winrm = WinRM::WinRMWebService.new(endpoint, :plaintext, :user => 'Vagrant', :pass => 'vagrant') | |
shell = winrm.open_shell | |
output = winrm.run_command shell, 'dir' | |
result = winrm.get_command_output(shell, output) | |
=begin | |
That returns: | |
{ | |
:data => [ | |
{ | |
:stdout => " Volume in drive C has no label.\r\n" | |
}, { | |
:stdout => " Volume Serial Number is B06B-7602\r\n\r\n Directory of C:\\Users\\Administrator\r\n\r\n13/12/2012 12:47 PM <DIR> .\r\n13/12/2012 12:47 PM <DIR> ..\r\n11/12/2012 09:49 PM <DIR> Contacts\r\n11/12/2012 09:49 PM <DIR> Desktop\r\n11/12/2012 09:49 PM <DIR> Documents\r\n13/12/2012 10:01 AM <DIR> Downloads\r\n11/12/2012 09:49 PM <DIR> Favorites\r\n11/12/2012 09:49 PM <DIR> Links\r\n11/12/2012 09:49 PM <DIR> Music\r\n13/12/2012 12:41 PM 63 password.inf\r\n11/12/2012 09:49 PM <DIR> Pictures\r\n11/12/2012 09:49 PM <DIR> Saved Games\r\n11/12/2012 09:49 PM <DIR> Searches\r\n13/12/2012 12:47 PM 1,056,768 secedit.sdb\r\n13/12/2012 12:44 PM 16,404 vbox-secpol.inf\r\n11/12/2012 09:49 PM <DIR> Videos\r\n 3 File(s) 1,073,235 bytes\r\n 13 Dir(s) 22,605,975,552 bytes free\r\n" | |
} | |
], | |
:exitcode => 0 | |
} | |
=end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment