Python Help

Type your comment> @acidbat said:

@PapyrusTheGuru said:
Hey AcidBat, since you have 0 (or very minimal knowledge) of python, I will try to explain as much as I can with my also limited knowledge of Python ■■■■■.

When you do s = winrm.Session('127.0.0.1', auth=('dude','dude')) You are making an instance of the winrm class with the Session being the method.

and at the second line you do r = session.run_ps("hostname") from my limited observation it seems to mean that you want to execute the cmdlet “hostname” in powershell, the only issue you are doing right now is the fact that you need to replace session with the svariable, and change print(result.std_out) to print(r.std_out)

I am currently at school so I can’t directly test this code myself, so here is the full code:

import winrm

s = winrm.Session('127.0.0.1', auth=('dude', 'dude'))
r = s.run_ps("hostname")
print(r.std_out)

Please let me know if this works!

EDIT: Forgot to mention, I am no prodigy/expert python programming of any kind, I simply wish to help you and take everything I (a noob) says with a grain of salt :smiley:

that actually worked like a charm with python3…

Thank you @PapyrusTheGuru & @Darvidor | your combined answers put me on the right track :slight_smile:

Super glad to hear that! I hope the project you’re currently working on will educate you a lot about Python, as it certainly is an amazing language. And two heads are better than one!