File tree Expand file tree Collapse file tree 1 file changed +12
-2
lines changed
winrm4j/src/main/java/io/cloudsoft/winrm4j/winrm Expand file tree Collapse file tree 1 file changed +12
-2
lines changed Original file line number Diff line number Diff line change @@ -30,8 +30,7 @@ public WinRmToolResponse executeScript(List<String> commands) {
3030 }
3131
3232 public WinRmToolResponse executeScript (String commands ) {
33- // TODO better support for address formats, host:port required
34- Builder builder = WinRmClient .builder ("http://" + address + "/wsman" );
33+ Builder builder = WinRmClient .builder (getEndpointUrl ());
3534 if (username != null && password != null ) {
3635 builder .credentials (username , password );
3736 }
@@ -48,6 +47,17 @@ public WinRmToolResponse executeScript(String commands) {
4847 }
4948 }
5049
50+ //TODO support https transport
51+ private String getEndpointUrl () {
52+ if (address .startsWith ("http:" ) || address .startsWith ("https:" )) {
53+ return address ;
54+ } else if (address .contains (":" )) {
55+ return "http://" + address + "/wsman" ;
56+ } else {
57+ return "http://" + address + ":5985/wsman" ;
58+ }
59+ }
60+
5161 public WinRmToolResponse executePs (List <String > commands ) {
5262 return executeScript (compilePs (joinPs (commands )));
5363 }
You can’t perform that action at this time.
0 commit comments