diff --git a/README.md b/README.md index 95a57ba..efa2b6c 100644 --- a/README.md +++ b/README.md @@ -64,6 +64,7 @@ For further information see: winrm-authtype="credssp"/> ``` +The username can be overwritten using a job input option called "username". ## Limitations diff --git a/contents/winrm-exec.py b/contents/winrm-exec.py index 87e3f53..2e5858b 100644 --- a/contents/winrm-exec.py +++ b/contents/winrm-exec.py @@ -45,7 +45,11 @@ endpoint=transport+'://'+args.hostname+':'+port -username = args.username.strip('\'') +if "RD_OPTION_USERNAME" in os.environ: + username = os.getenv("RD_OPTION_USERNAME").strip('\'') +else: + username = args.username.strip('\'') + if(debug): print "------------------------------------------" diff --git a/contents/winrm-filecopier.py b/contents/winrm-filecopier.py index 4d524e9..bbb51a7 100644 --- a/contents/winrm-filecopier.py +++ b/contents/winrm-filecopier.py @@ -109,15 +109,20 @@ def winrm_upload( if "RD_CONFIG_NOSSL" in os.environ: nossl = os.getenv("RD_CONFIG_NOSSL") +if "RD_OPTION_USERNAME" in os.environ: + username = os.getenv("RD_OPTION_USERNAME").strip('\'') +else: + username = args.username.strip('\'') + endpoint=transport+'://'+args.hostname+':'+port if(nossl): - session = winrm.Session(endpoint, auth=(args.username, password), + session = winrm.Session(endpoint, auth=(username, password), transport=authentication, server_cert_validation='ignore') else: - session = winrm.Session(endpoint, auth=(args.username, password), + session = winrm.Session(endpoint, auth=(username, password), transport=authentication) copy = CopyFiles(session)