def run_command(
            self, shell_id, command, arguments=(), console_mode_stdin=True,
            skip_cmd_shell=False):
        """
        Run a command on a machine with an open shell
        @param string shell_id: The shell id on the remote machine.
         See #open_shell
        @param string command: The command to run on the remote machine
        @param iterable of string arguments: An array of arguments for this
         command
        @param bool console_mode_stdin: (default: True)
        @param bool skip_cmd_shell: (default: False)
        @return: The CommandId from the SOAP response.
         This is the ID we need to query in order to get output.
        @rtype string
        """
        req = {'env:Envelope': self._get_soap_header(
            resource_uri='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd',  # NOQA
            action='http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command',  # NOQA
            shell_id=shell_id)}
        header = req['env:Envelope']['env:Header']
        header['w:OptionSet'] = {
            'w:Option': [
                {
                    '@Name': 'WINRS_CONSOLEMODE_STDIN',
                    '#text': str(console_mode_stdin).upper()
                },
                {
                    '@Name': 'WINRS_SKIP_CMD_SHELL',
                    '#text': str(skip_cmd_shell).upper()
                }
            ]
        }
        cmd_line = req['env:Envelope'].setdefault(
            'env:Body', {}).setdefault('rsp:CommandLine', {})
        cmd_line['rsp:Command'] = {'#text': command}
        if arguments:
            unicode_args = [a if isinstance(a, text_type) else a.decode('utf-8') for a in arguments]
            cmd_line['rsp:Arguments'] = u' '.join(unicode_args)

        res = self.send_message(xmltodict.unparse(req))
        root = ET.fromstring(res)
        command_id = next(
            node for node in root.findall('.//*')
            if node.tag.endswith('CommandId')).text
        return command_id
def run_command ( self , shell_id , command , arguments = ( ) , console_mode_stdin = True , skip_cmd_shell = False ) : req = { 'env:Envelope' : self . _get_soap_header ( resource_uri = 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/cmd' , action = 'http://schemas.microsoft.com/wbem/wsman/1/windows/shell/Command' , shell_id = shell_id ) } header = req [ 'env:Envelope' ] [ 'env:Header' ] header [ 'w:OptionSet' ] = { 'w:Option' : [ { '@Name' : 'WINRS_CONSOLEMODE_STDIN' , '#text' : str ( console_mode_stdin ) . upper ( ) } , { '@Name' : 'WINRS_SKIP_CMD_SHELL' , '#text' : str ( skip_cmd_shell ) . upper ( ) } ] } cmd_line = req [ 'env:Envelope' ] . setdefault ( 'env:Body' , { } ) . setdefault ( 'rsp:CommandLine' , { } ) cmd_line [ 'rsp:Command' ] = { '#text' : command } if arguments : unicode_args = [ a if isinstance ( a , text_type ) else a . decode ( 'utf-8' ) for a in arguments ] cmd_line [ 'rsp:Arguments' ] = u' ' . join ( unicode_args ) res = self . send_message ( xmltodict . unparse ( req ) ) root = ET . fromstring ( res ) command_id = next ( node for node in root . findall ( './/*' ) if node . tag . endswith ( 'CommandId' ) ) . text return command_id
Run a command on a machine with an open shell
        @param string shell_id: The shell id on the remote machine.
         See #open_shell
        @param string command: The command to run on the remote machine
        @param iterable of string arguments: An array of arguments for this
         command
        @param bool console_mode_stdin: (default: True)
        @param bool skip_cmd_shell: (default: False)
        @return: The CommandId from the SOAP response.
         This is the ID we need to query in order to get output.
        @rtype string