ansible的Windows模块win_command或win_shell的特权升级问题

问题描述

我正在用拳头砸墙,试图使用ansible中的win_shell和/或win_command远程访问copy-Item。

请注意,我能够在ansible尝试管理的服务器上本地执行此操作。

这是最新的代码

    - name: Arg Testing - Win Command
      win_command: powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NonInteractive -
      args:
        stdin: copy-Item –Path "{{ source_file_path }}" –Destination "\\{{ test_server }}\{{ drive_letter }}${{ folder_name1 + folder_name2 }}"
      delegate_to: "{{ server1 }}"

这是我收到的错误

fatal: [ansible_server -> server1]: Failed! => {"changed": true,"cmd": "powershell.exe -ExecutionPolicy Bypass -WindowStyle Hidden -NonInteractive -","delta": "0:00:00.390641","end": "2020-08-11 04:22:08.804385","msg": "non-zero return code","rc": 1,"start": "2020-08-11 04:22:08.413743","stderr": "copy-Item : Access is denied\r\nAt line:1 char:1\r\n+ copy-Item –Path \"this.is.source.path\" –Dest ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : NotSpecified: (:) [copy-Item],UnauthorizedAccessException\r\n    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.copyitemcommand\r\n \r\n","stderr_lines": ["copy-Item : Access is denied","At line:1 char:1","+ copy-Item –Path \"this.is.source.path\" –Dest ...","+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~","    + CategoryInfo          : NotSpecified: (:) [copy-Item],UnauthorizedAccessException","    + FullyQualifiedErrorId : System.UnauthorizedAccessException,Microsoft.PowerShell.Commands.copyitemcommand"," "],"stdout": "","stdout_lines": []}

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)