3

I read this whole thread about how to pass boolean values to a parameter to powershell on Linux. Nothing worked for me.

My code in Ansible is as follows:

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

I've used many variants, such as -ParticipateInCEIP:False, or -ParticipateInCEIP False, or -ParticipateInCEIP $false, but I get always the same error, that it expects boolean, but I sent string.

I am running this Ansible task against a Linux machine with Powershell installed.

Any tips on how to make it work?

Best,

Francis

francisaugusto
  • 1,077
  • 1
  • 12
  • 29

1 Answers1

5

When you shell: pwsh -Command "something -switch:$powershellVariable", with double quotes, $powershellVariable will be evaluated by the Linux shell before passing it to PowerShell.

Unless you have an actual $powershellVariable defined in your shell, it will be passed to PowerShell as something -switch:

Try rewriting with single quotes:

  shell: pwsh -Command 'Set-PowerCLIConfiguration -Scope AllUsers -ParticipateInCEIP:$False -Confirm:$False -InvalidCertificateAction Ignore'
mklement0
  • 382,024
  • 64
  • 607
  • 775
Magnus
  • 66
  • 2