Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'winrm'
- conn = WinRM::Connection.new(
- endpoint: 'https://10.10.10.103:5986/wsman',
- transport: :ssl,
- user: './certnew.cer',
- password: 'Ashare1972',
- client_cert: './certnew.cer',
- client_key: './amanda_priv.key',
- key_pass: 'Ashare1972',
- :no_ssl_peer_verification => true
- )
- command=""
- conn.shell(:powershell) do |shell|
- until command == "exit\n" do
- output = shell.run("-join($id,'PS ',$(whoami),'@',$env:computername,' ',$((gi $pwd).Name),'> ')")
- print(output.output.chomp)
- command = gets
- output = shell.run(command) do |stdout, stderr|
- STDOUT.print stdout
- STDERR.print stderr
- end
- end
- puts "Exiting with code #{output.exitcode}"
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement