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

1
  • Try -ParticipateInCEIP:0 (or -ParticipateInCEIP:([bool]0)) Commented Mar 23, 2021 at 12:00

1 Answer 1

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'
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.