-
Notifications
You must be signed in to change notification settings - Fork 119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Interfaces for 2.0 (WinRM and Shell) #115
Comments
Custom shell example that would make me 😄 require "winrm/extensions/chocolatey"
chocolatey = winrm.shell(:chocolatey)
chocolatey.install_chocolatey unless chocolatey.installed?
chocolatey.install("git")
if chocolatey.installed? "ruby"
ruby_version = chocolatey.version("ruby")
puts "Time to upgrade Ruby?" unless ruby_version.found != ruby_version.latest
else
chocolatey.install("ruby -x86")
chocolatey.install("ruby2.devkit -x86")
end Of course, in this case you may be better off with doing that all in PowerShell, but there's cases where something like that could be useful. |
👍 breaking apart WinRMWebService into multiple classes. I like the idea of being able to open a PowerShell session and call |
this was fixed via #191 |
This is a proposal for 2.0, though it could be possible to add new interfaces in 1.4.x as long as the old interfaces are still around (possibly deprecated).
I think it'd be nice to add Shell and Command classes along with Output (added in #103). I hinted towards this in #114 (selecting FileManagers) and #103 (comparing w/ mixlib-shellout), so figured I'd write up an actual proposal.
The WinRM class would represent a WinRM connection. Once you have a connection you can create objects that will interact with that session, like
winrm.file_manager
(see example in #114) orwinrm.shell
:The default shell could be a generic or "multi-shell" for people that let's you switch back and forth between different shells, closer to backwards-compatible with the current interface. So these would all be equivalent:
However, since the Shell represents a session I think the second approach is a better usage pattern:
WinRM::Shell
subclasses likeWinRM::PowerShell
), likePowerShell#import_module
.WinRM::PowerShell
would behave just like launching a new PowerShell window - variable assignments and imported modules will be remembered across commands within a session, but not across sessions:In the example above, imagine that
shell.import_module(WinRM::Extensions::Cryptography)
imports this module into the powershell session.I think all of this has a few advantages:
WinRM.new
is easier to remember thanWinRM:: WinRMWebService.new
WinRM.new
and leaveWinRM:: WinRMWebService.new
as a (possibly deprecated) backwards-compatible interface.Shell
class withCmdShell
,PowerShell
, andWQLShell
subclasses will be easier to read than having WQL code inWinRM::WinRMWebService
.#shell
method could allow for shell-specific features (likePowerShell#import_module
in the example above).The text was updated successfully, but these errors were encountered: