微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

通过 Ansible 运行 Powershell 脚本不会产生输出文件

如何解决通过 Ansible 运行 Powershell 脚本不会产生输出文件

我有一个 PowerShell 脚本,它在本地执行时可以从本地服务器运行另一个脚本,并在标准文本文件生成结果。

但是,当我通过 Ansible Runbook 运行相同的脚本时,没有产生任何结果

PowerShell 脚本是-

# runcis.ps1
# Import DBA functions 
# Construct local instance name and execute Getter script,format output and redirect to 
# a text file on the local server
  .\ImportAllLmesqlDbaFunctions.ps1

$inst = (get-itemproperty 'HKLM:\SOFTWARE\Microsoft\Microsoft sql Server').InstalledInstances
$instance = "$env:COmpuTERNAME\$inst"

Get-CISAdHocdistQueries -Instances $instance| format-table -AutoSize > c:\cis\output.txt 

Ansible Runbook 是-

---


# Below will create directory if not existing

- name: copy Powershell scripts to Remote Server 
  copy:
    src: cis
    dest: c:\
- name: Run CIS powershell script on the Remote Server
  win_shell: C:\cis\runcis.ps1 

非常感谢您的帮助。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。