public Map < String , String > runCommand ( WSManRequestInputs wsManRequestInputs ) throws RuntimeException , IOException , InterruptedException , ParserConfigurationException , TransformerException , XPathExpressionException , TimeoutException , URISyntaxException , SAXException { HttpClientService csHttpClient = new HttpClientService ( ) ; HttpClientInputs httpClientInputs = new HttpClientInputs ( ) ; URL url = buildURL ( wsManRequestInputs , WSMAN_RESOURCE_URI ) ; httpClientInputs = setCommonHttpInputs ( httpClientInputs , url , wsManRequestInputs ) ; String shellId = createShell ( csHttpClient , httpClientInputs , wsManRequestInputs ) ; WSManUtils . validateUUID ( shellId , SHELL_ID ) ; String commandStr = WSManUtils . constructCommand ( wsManRequestInputs ) ; String commandId = executeCommand ( csHttpClient , httpClientInputs , shellId , wsManRequestInputs , commandStr ) ; WSManUtils . validateUUID ( commandId , COMMAND_ID ) ; Map < String , String > scriptResults = receiveCommandResult ( csHttpClient , httpClientInputs , shellId , commandId , wsManRequestInputs ) ; deleteShell ( csHttpClient , httpClientInputs , shellId , wsManRequestInputs ) ; return scriptResults ; }
Executes a command on a remote shell by communicating with the WinRM server from the remote host . Method creates a shell runs a command on the shell waits for the command execution to finnish retrieves the result then deletes the shell .