无法将字符串转换为布尔值-在linux上可以使用powershell

我阅读了有关如何将布尔值传递给 Linux 上的 powershell 参数的整个线程。没有什么对我有用。

我在 Ansible 中的代码如下:

- name: Install PowerCLI
  shell: pwsh -Command "Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP:$False -Confirm:$False -InvalidCertificateAction Ignore"

我使用了许多变体,例如-ParticipateInCEIP:False, or -ParticipateInCEIP False, or -ParticipateInCEIP $false,但我总是得到相同的错误,它期望布尔值,但我发送了字符串。

我正在对安装了 Powershell 的 Linux 机器运行这个 Ansible 任务。

有关如何使其工作的任何提示?

最好的事物,

弗朗西斯

回答

当您shell: pwsh -Command "something -switch:$powershellVariable"使用双引号时,$powershellVariable 将在将其传递给 PowerShell 之前由 Linux shell 进行评估。

除非您在 shell 中定义了实际的 $powershellVariable,否则它将作为 something -switch:

尝试用单引号重写:

  shell: pwsh -Command 'Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP:$False -Confirm:$False -InvalidCertificateAction Ignore'


以上是无法将字符串转换为布尔值-在linux上可以使用powershell的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>