gpt4 book ai didi

How to create a directory with a UNC path in a powershell script with ansible?(如何使用Anable在PowerShell脚本中创建一个带有UNC路径的目录?)

转载 作者:bug小助手 更新时间:2023-10-24 17:54:44 26 4
gpt4 key购买 nike



I'm trying to create a directory on a network drive using ansible (version 2.9). I made a powershell script which I've copied to the server and I'm calling via win_command.

我正在尝试使用Ansible(2.9版)在网络驱动器上创建一个目录。我制作了一个PowerShell脚本,并将其复制到服务器上,然后通过Win_Command调用它。


New-Item -ItemType Directory -Force -Path \\\\server\path\a\b

When I run the script on a Windows server, it correctly creates the directory at \\server\path\a\b, however, when I run it via ansible, it creates a directory at C:\server\path\a\b.

当我在Windows服务器上运行该脚本时,它正确地在\\SERVER\PATH\a\b处创建了目录,但是,当我通过Anable运行它时,它在C:\SERVER\PATH\a\b处创建了一个目录。


- name: Run create dir script
win_command: 'powershell C:\Temp\script.ps1'
become: yes
vars:
ansible_become_user: "network_user"
ansible_become_pass: "network_password"
ansible_become_method: runas
ansible_become_flags: logon_type=new_credentials logon_flags=netcredentials_only


How do I get it to not create the directory in the C:\ drive?

如何使其不在C:\驱动器中创建目录?


更多回答
优秀答案推荐
更多回答

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com