PowerCli, Docker And The Dollar Sign


You can execute vSphere's Powercli from your Linux box, without the need to run Windows. Beautiful, isn't it? And gets better: there is a docker image for that (reference). It's as easy as:

docker run --rm -it --entrypoint='/usr/bin/powershell' vmware/powerclicore

But then you create a docker-composer file and want to execute a cmdlet that has a dollar sign ($) diretcly Docker's entrypoint. Didn't find the solution on the web. Only by chance, and after few hours of trial and error, the beauty is revealed: have to double scape the dollar sign.

Turn this:

entrypoint: |
  bash -c '/usr/bin/powershell <<EOF
    Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:$false
...
 EOF'

Into this:

entrypoint: |
  bash -c '/usr/bin/powershell <<EOF
    Set-PowerCLIConfiguration -InvalidCertificateAction Ignore -Confirm:\$$false
...
 EOF'

And there you go.

(Issue reported on Docker PowerCli Github)

Comments

Popular posts from this blog

Instalação eToken Pro no Ubuntu 18.04 para acesso ao eCAC da RFB

Integrating Drupal 8 Webforms Submissions and Rocket Chat

Ubuntu 17.10 - CIFS Mount Error Code -5