winrm协议python远程执行windows命令报错

    科技2025-09-15  34

    Traceback (most recent call last): File "D:\python\lib\site-packages\winrm\transport.py", line 329, in _send_message_request response.raise_for_status() File "D:\python\lib\site-packages\requests\models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 401 Client Error: for url: http://xx.xx.xx.xx4:5985/wsman During handling of the above exception, another exception occurred: Traceback (most recent call last): File "G:/PythonWorkspace/workproject//winrm01.py", line 13, in <module> winCMD() File "G:/PythonWorkspace/workproject//winrm01.py", line 8, in winCMD ret = wintest.run_cmd(cmd) File "D:\python\lib\site-packages\winrm\__init__.py", line 39, in run_cmd shell_id = self.protocol.open_shell() File "D:\python\lib\site-packages\winrm\protocol.py", line 166, in open_shell res = self.send_message(xmltodict.unparse(req)) File "D:\python\lib\site-packages\winrm\protocol.py", line 243, in send_message resp = self.transport.send_message(message) File "D:\python\lib\site-packages\winrm\transport.py", line 323, in send_message response = self._send_message_request(prepared_request, message) File "D:\python\lib\site-packages\winrm\transport.py", line 333, in _send_message_request raise InvalidCredentialsError("the specified credentials were rejected by the server") winrm.exceptions.InvalidCredentialsError: the specified credentials were rejected by the server
    Processed: 0.010, SQL: 8