Created
July 8, 2016 16:36
-
-
Save rayterrill/78aec44412375e25e92c6a62cbad9191 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#requires the winrm gem - sudo gem install -r winrm | |
require 'winrm' | |
endpoint = 'http://SERVER_FQDN:5985/wsman' | |
winrm = WinRM::WinRMWebService.new(endpoint, :negotiate, :user => 'USERNAME', :pass => 'PASSWORD') | |
winrm.create_executor do |executor| | |
executor.run_powershell_script("Get-Service | Where-Object {$_.Name -Like '*SQL*'}") do |stdout, stderr| | |
#executor.run_cmd("ipconfig /all") do |stdout, stderr| #use this if you'd rather run a command prompt | |
STDOUT.print stdout | |
STDERR.print stderr | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment